本文整理汇总了C#中X360.IO.DJsIO.BlockCountSTFS方法的典型用法代码示例。如果您正苦于以下问题:C# DJsIO.BlockCountSTFS方法的具体用法?C# DJsIO.BlockCountSTFS怎么用?C# DJsIO.BlockCountSTFS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X360.IO.DJsIO
的用法示例。
在下文中一共展示了DJsIO.BlockCountSTFS方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: xReplace
internal bool xReplace(DJsIO xIOin)
{
if (!Opened)
ReadBlocks();
if (!xIOin.Accessed || xIOin.Length > 0xFFFFFFFF)
return false;
try
{
// Allocates new blocks for new data
xPackage.AddToLog("Allocating blocks");
BlockRecord[] xEntAlloc = xPackage.xAllocateBlocks(xPackage.xCurEntBlckCnt, 0);
BlockRecord[] xFileAlloc = xPackage.xAllocateBlocks(xIOin.BlockCountSTFS(), xEntAlloc[xEntAlloc.Length - 1].ThisBlock + 1);
// Updates entry
xPackage.AddToLog("Updating entry");
xStartBlock = xFileAlloc[0].ThisBlock;
xSize = (int)xIOin.Length;
xBlockCount = xIOin.BlockCountSTFS();
if (xPackage.xDoAdd(ref xIOin, ref xEntAlloc, ref xFileAlloc))
{
xPackage.xDeleteChain(xBlocks);
ClearBlocks();
return true;
}
return false;
}
catch { ClearBlocks(); return false; }
}
示例2: xAddFile
/// <summary>
/// Adds a file to the package
/// </summary>
/// <param name="xIOIn"></param>
/// <param name="xFileName"></param>
/// <param name="Folder"></param>
/// <returns></returns>
bool xAddFile(DJsIO xIOIn, string xFileName, ushort Folder)
{
try
{
if (xIOIn == null || !xIOIn.Accessed || xIOIn.Length > ((xSTFSStruct.SpaceBetween[2] - 1) << 0xC))
return (xActive = false);
foreach (FileEntry m in xFileDirectory)
{
if (m.FolderPointer == Folder && m.Name == xFileName)
return (xActive = false);
}
// Allocates blocks
AddToLog("Allocating blocks");
BlockRecord[] xEntAlloc = xAllocateBlocks(xNewEntBlckCnt(1), 0);
BlockRecord[] xFileAlloc = xAllocateBlocks(xIOIn.BlockCountSTFS(), xEntAlloc[xEntAlloc.Length - 1].ThisBlock + 1);
// Adds new file info
AddToLog("Adding file information");
ItemEntry x = new ItemEntry(xFileName, (int)xIOIn.Length, false, (ushort)(xFileDirectory.Count + xFolderDirectory.Count), Folder, this);
FileEntry y = new FileEntry(x);
y.xStartBlock = xFileAlloc[0].ThisBlock;
xFileDirectory.Add(y);
return xDoAdd(ref xIOIn, ref xEntAlloc, ref xFileAlloc);
}
catch (Exception x) { return (xActive = false); throw x; }
}
示例3: xInject
internal bool xInject(DJsIO xIOin)
{
if (!Opened && !ReadBlocks())
return false;
try
{
if (xIOin.Length > 0xFFFFFFFF)
return false;
uint y = xIOin.BlockCountSTFS();
List<BlockRecord> x = xBlocks.ToList();
List<BlockRecord> xdel = null;
if (y > xBlocks.Length)// Allocates data for blocks needed
x.AddRange(xPackage.xAllocateBlocks((uint)(y - xBlocks.Length), 0));
else
{
xdel = new List<BlockRecord>();
for (int i = (int)y; i < x.Count; i++)
{
xdel.Add(x[i]);
x.RemoveAt(i--);
}
}
bool success = xPackage.xWriteTo(ref xIOin, x.ToArray());
if (success)
{
xBlocks = x.ToArray();
if (xdel != null && xdel.Count != 0)
xPackage.xDeleteChain(xdel.ToArray());
}
return (success & ClearBlocks());
}
catch { ClearBlocks(); return false; }
}
示例4: xWriteTo
/// <summary>
/// Writes a file via blocks
/// </summary>
/// <param name="xIOIn"></param>
/// <param name="xBlocks"></param>
/// <returns></returns>
internal bool xWriteTo(ref DJsIO xIOIn, BlockRecord[] xBlocks)
{
if (!xIOIn.Accessed || (xIOIn.BlockCountSTFS() != xBlocks.Length))
return false;
try
{
xIOIn.Position = 0;
for (int i = 0; i < xBlocks.Length - 1; i++)
{
// Finds spot and writes block of data
xIO.Position = GenerateDataOffset(xBlocks[i].ThisBlock);
xIO.Write(xIOIn.ReadBytes(0x1000));
}
xIO.Position = GenerateDataOffset(xBlocks[xBlocks.Length - 1].ThisBlock);
xIO.Write(xIOIn.ReadBytes(xIOIn.BlockRemainderSTFS()));
xIO.Flush();
return true;
}
catch { return false; }
}