当前位置: 首页>>代码示例>>C#>>正文


C# DJsIO.BlockCountFATX方法代码示例

本文整理汇总了C#中X360.IO.DJsIO.BlockCountFATX方法的典型用法代码示例。如果您正苦于以下问题:C# DJsIO.BlockCountFATX方法的具体用法?C# DJsIO.BlockCountFATX怎么用?C# DJsIO.BlockCountFATX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在X360.IO.DJsIO的用法示例。


在下文中一共展示了DJsIO.BlockCountFATX方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddFolder

 /* Note: Have plans for safer and better manipulation to prevent
  * minimal block loss to human error */
 /// <summary>
 /// Adds a folder
 /// </summary>
 /// <param name="FolderName"></param>
 /// <returns></returns>
 public bool AddFolder(string FolderName)
 {
     FolderName.IsValidXboxName();
     if (xDrive.ActiveCheck())
         return false;
     try
     {
         FATXReadContents xconts = xRead();
         foreach (FATXFolderEntry x in xconts.xfolds)
         {
             if (x.Name == FolderName)
                 return (xDrive.xActive = false);
         }
         DJsIO xIOIn = new DJsIO(new byte[Partition.xBlockSize], true);
         uint xnew = 0;
         long xpos = GetNewEntryPos(out xnew);
         if (xpos == -1)
             return (xDrive.xActive = false);
         uint[] blocks = Partition.xTable.GetNewBlockChain(xIOIn.BlockCountFATX(Partition), xnew + 1);
         if (blocks.Length == 0)
             return (xDrive.xActive = false);
         if (!Partition.WriteFile(blocks, ref xIOIn))
             return (xDrive.xActive = false);
         FATXEntry y = new FATXEntry(FolderName, blocks[0], (int)xIOIn.Length, xpos, true, ref xDrive);
         if (!y.xWriteEntry())
             return (xDrive.xActive = false);
         if (xnew > 0)
         {
             List<uint> fileblocks = new List<uint>(Partition.xTable.GetBlocks(xStartBlock));
             fileblocks.Add(xnew);
             uint[] xtemp = fileblocks.ToArray();
             if (!Partition.xTable.WriteChain(ref xtemp))
                 return (xDrive.xActive = false);
         }
         if (!Partition.xTable.WriteChain(ref blocks))
             return (xDrive.xActive = false);
         if (Partition.WriteAllocTable())
             return !(xDrive.xActive = false);
         return (xDrive.xActive = false);
     }
     catch { return xDrive.xActive = false; }
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:49,代码来源:Entries.cs

示例2: AddFile

 /// <summary>
 /// Adds a file
 /// </summary>
 /// <param name="FileName"></param>
 /// <param name="FileLocation"></param>
 /// <param name="xType"></param>
 /// <returns></returns>
 public bool AddFile(string FileName, string FileLocation, AddType xType)
 {
     FileName.IsValidXboxName();
     if (xDrive.ActiveCheck())
         return false;
     DJsIO xIOIn = null;
     try { xIOIn = new DJsIO(FileLocation, DJFileMode.Open, true); }
     catch { return (xDrive.xActive = false); }
     try
     {
         FATXReadContents xconts = xRead();
         foreach (FATXFileEntry x in xconts.xfiles)
         {
             if (x.Name == FileName)
             {
                 bool xreturn = false;
                 if (xType == AddType.NoOverWrite)
                      return (xDrive.xActive = false);
                 else if (xType == AddType.Inject)
                     xreturn = x.xInject(xIOIn);
                 else xreturn = x.xReplace(xIOIn);
                 return (xreturn & !(xDrive.xActive = false));
             }
         }
         uint xnew = 0;
         long xpos = GetNewEntryPos(out xnew);
         if (xpos == -1)
             return (xDrive.xActive = false);
         uint[] blocks = Partition.xTable.GetNewBlockChain(xIOIn.BlockCountFATX(Partition), xnew + 1);
         if (blocks.Length == 0)
             return (xDrive.xActive = false);
         if (!Partition.WriteFile(blocks, ref xIOIn))
             return (xDrive.xActive = false);
         FATXEntry y = new FATXEntry(FileName, blocks[0], (int)xIOIn.Length, xpos, false, ref xDrive);
         if (!y.xWriteEntry())
             return (xDrive.xActive = false);
         if (xnew > 0)
         {
             List<uint> fileblocks = new List<uint>(Partition.xTable.GetBlocks(xStartBlock));
             fileblocks.Add(xnew);
             uint[] xtemp = fileblocks.ToArray();
             if (!Partition.xTable.WriteChain(ref xtemp))
                 return (xDrive.xActive = false);
         }
         if (!Partition.xTable.WriteChain(ref blocks))
             return (xDrive.xActive = false);
         if (Partition.WriteAllocTable())
             return !(xDrive.xActive = false);
         return (xDrive.xActive = false);
     }
     catch { xIOIn.Close(); return (xDrive.xActive = false); }
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:59,代码来源:Entries.cs

示例3: xReplace

 internal bool xReplace(DJsIO xIOIn)
 {
     uint bu = xStartBlock;
     int size = xSize;
     try
     {
         uint[] curblocks = Partition.xTable.GetBlocks(xStartBlock);
         uint[] blocks = Partition.xTable.GetNewBlockChain(xIOIn.BlockCountFATX(Partition), 1);
         if (blocks.Length == 0)
             throw new Exception();
         if (!Partition.xTable.WriteChain(ref blocks))
             throw new Exception();
         if (!Partition.xTable.DC(ref curblocks))
             throw new Exception();
         xIOIn.Position = 0;
         xDrive.GetIO();
         if (!Partition.WriteFile(blocks, ref xIOIn))
             throw new Exception();
         if (!Partition.WriteAllocTable())
             throw new Exception();
         base.xStartBlock = blocks[0];
         base.xSize = (int)xIOIn.Length;
         xIOIn.Close();
         return xWriteEntry();
     }
     catch { xIOIn.Close(); base.xStartBlock = bu; base.xSize = size; return false; }
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:27,代码来源:Entries.cs

示例4: xInject

 internal bool xInject(DJsIO xIOIn)
 {
     List<uint> blocks = new List<uint>(Partition.xTable.GetBlocks(xStartBlock));
     if (blocks.Count == 0)
         throw new Exception();
     uint xct = xIOIn.BlockCountFATX(Partition);
     if (blocks.Count < xct)
     {
         uint[] blocks2 = Partition.xTable.GetNewBlockChain((uint)(xct - blocks.Count), 1);
         if (blocks2.Length == 0)
             throw new Exception();
         blocks.AddRange(blocks2);
         uint[] x = blocks.ToArray();
         if (!Partition.xTable.WriteChain(ref x))
             throw new Exception();
     }
     else if (blocks.Count > xct)
     {
         uint[] xUnneeded = new uint[blocks.Count - xct];
         for (uint i = xct; i < blocks.Count; i++)
         {
             xUnneeded[(int)i] = i;
             blocks.RemoveAt((int)i--);
         }
         if (!Partition.xTable.DC(ref xUnneeded))
             throw new Exception();
     }
     xIOIn.Position = 0;
     xDrive.GetIO();
     foreach (uint i in blocks)
     {
         xDrive.xIO.Position = Partition.BlockToOffset(i);
         xDrive.xIO.Write(xIOIn.ReadBytes(Partition.xBlockSize));
     }
     if ((xSize == 0 || (uint)(((xSize - 1) / Partition.xBlockSize) + 1) != xct) &&
         !Partition.WriteAllocTable())
         throw new Exception();
     xSize = (int)xIOIn.Length;
     xIOIn.Close();
     return xWriteEntry();
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:41,代码来源:Entries.cs

示例5: AddFolder

        /* Note: Have plans for safer and better manipulation to prevent
         * minimal block loss to human error */
        /// <summary>
        /// Adds a folder
        /// </summary>
        /// <param name="FolderName"></param>
        /// <returns></returns>
        public bool AddFolder(string FolderName)
        {
            if (!VariousFunctions.IsValidXboxName(FolderName))
                return false;

            if (xDrive.ActiveCheck())
                return false;
            try
            {
                FATXReadContents xconts = xRead();
                if (xconts == null)
                    return false;
                foreach (FATXFolderEntry x in xconts.xfolds)
                {
                    if (string.Compare(x.Name , FolderName,true)==0)
                        return (xDrive.xActive = false);
                }

                var b = new byte[Partition.xBlockSize];
                for (int x = 0; x < 4; x++)
                    b[x] = 0x00;

                for (int x = 4; x < b.Length; x++)
                {
                    b[x] = 0xFF;
                }
                DJsIO xIOIn = new DJsIO(b, true);
                uint xnew = 0;
                long xpos = GetNewEntryPos(out xnew);
                if (xpos == -1)
                    return (xDrive.xActive = false);

                var blockCount = xIOIn.BlockCountFATX(Partition);
                var xnewIndex = xnew + 1;

                uint[] blocks = Partition.xTable.GetNewBlockChain(blockCount, xnewIndex);
                if (blocks.Length == 0)
                    return (xDrive.xActive = false);

                if (!Partition.WriteFile(blocks, ref xIOIn))
                    return (xDrive.xActive = false);

                FATXEntry y = new FATXEntry(this, FolderName, blocks[0],
                    (int)xIOIn.Length, xpos, true, ref xDrive);

                //y.FatEntry = new FATXEntry64(xData);

                y.SetAtts(this.Partition);
                if (!y.xWriteEntry())
                    return (xDrive.xActive = false);

                if (xnew > 0)
                {
                    var fileblocks = Partition.xTable.GetBlocks(xStartBlock).ToList();
                    fileblocks.Add(xnew);

                    uint[] xtemp = fileblocks.ToArray();

                    if (!Partition.xTable.WriteChain(ref xtemp))
                        return (xDrive.xActive = false);
                }

                if (!Partition.xTable.WriteChain(ref blocks))
                    return (xDrive.xActive = false);

                if (Partition.WriteAllocTable())
                    return !(xDrive.xActive = false);

                return (xDrive.xActive = false);
            }
            catch { return xDrive.xActive = false; }
        }
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:79,代码来源:Entries.cs

示例6: AddFile

        public bool AddFile(string FileName, byte[] fileData, AddType xType)
        {
            if (!VariousFunctions.IsValidXboxName(FileName))
                return false;

            if (xDrive.ActiveCheck())
                return false;

            DJsIO xIOIn = null;
            byte[] b = fileData;
            xIOIn = new DJsIO(b, true);

            try
            {
                FATXReadContents xconts = xRead();
                foreach (FATXFileEntry x in xconts.xfiles)
                {
                    if (string.Compare(x.Name, FileName, true) == 0)
                    {
                        bool xreturn = false;
                        if (xType == AddType.NoOverWrite)
                        {
                            xIOIn.Close();
                            return (xDrive.xActive = false);
                        }
                        else if (xType == AddType.Inject)
                        {
                            xreturn = x.xInject(xIOIn);
                        }
                        else
                        {
                            xreturn = x.xReplace(xIOIn);
                        }
                        xIOIn.Close();
                        return (xreturn & !(xDrive.xActive = false));
                    }
                }
                uint xnew = 0;
                long xpos = GetNewEntryPos(out xnew);
                if (xpos == -1)
                    return (xDrive.xActive = false);

                var count = xIOIn.BlockCountFATX(Partition);

                uint[] blocks = Partition.xTable.GetNewBlockChain(count, xnew + 1);

                if (blocks.Length == 0)
                    return (xDrive.xActive = false);

                if (!Partition.WriteFile(blocks, ref xIOIn))
                    return (xDrive.xActive = false);

                FATXEntry y = new FATXEntry(this,
                    FileName,
                    blocks[0], (int)xIOIn.Length,
                    xpos, false, ref xDrive);

                if (!y.xWriteEntry())
                    return (xDrive.xActive = false);

                if (xnew > 0)
                {
                    var filebx = Partition.xTable.GetBlocks(xStartBlock);
                    List<uint> fileblocks = new List<uint>(filebx);

                    fileblocks.Add(xnew);

                    uint[] xtemp = fileblocks.ToArray();

                    if (!Partition.xTable.WriteChain(ref xtemp))
                        return (xDrive.xActive = false);
                }

                if (!Partition.xTable.WriteChain(ref blocks))
                    return (xDrive.xActive = false);

                if (Partition.WriteAllocTable())
                    return !(xDrive.xActive = false);

                return (xDrive.xActive = false);
            }
            catch { xIOIn.Close(); return (xDrive.xActive = false); }
        }
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:83,代码来源:Entries.cs


注:本文中的X360.IO.DJsIO.BlockCountFATX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。