Пример #1
0
 /// <summary>
 /// Permits to remove a NoobDirectory by passing it
 /// </summary>
 /// <param name="noobDirectory">The NoobDirectory to remove</param>
 private void RemoveDirectory(NoobDirectory noobDirectory)
 {
     NoobDirectory[] subdirs = noobDirectory.GetDirs();
     for (int i = 0; i < subdirs.Length; i++)
     {
         noobDirectory.RemoveDirectory(subdirs[i]);
     }
     NoobFile[] subfiles = noobDirectory.GetFiles();
     for (int i = 0; i < subdirs.Length; i++)
     {
         noobDirectory.RemoveFile(subfiles[i].Name);
     }
     NoobFileSystem.ClearBlocks(noobDirectory.StartBlock);
     DeleteBlock(noobDirectory.StartBlock);
 }
Пример #2
0
        /// <summary>
        /// Permits to remove a NoobFile by passing it's name
        /// </summary>
        /// <param name="Name">The NoobFile's name to remove</param>
        public void RemoveFile(String Name)
        {
            NoobFile[] files = GetFiles();
            bool       found = false;
            int        index = 0;

            for (int i = 0; i < files.Length; i++)
            {
                if (files[i].Name == Name)
                {
                    index = i;
                    found = true;
                    break;
                }
            }
            if (found)
            {
                NoobFileSystem.ClearBlocks(files[index].StartBlock);
                DeleteBlock(files[index].StartBlock);
            }
        }
        /// <summary>
        /// Writes all the specified Bytes into the file
        /// </summary>
        /// <param name="Data">The array Byte to write into file</param>
        public void WriteAllBytes(Byte[] Data)
        {
            if (_StartBlock.NextBlock != 0)
            {
                NoobFileSystem.ClearBlocks(_StartBlock);
                _StartBlock.NextBlock = 0;
                NoobFSBlock.Write(NoobFileSystem.mFS.Partition, _StartBlock);
            }
            int         index = 0;
            NoobFSBlock curb  = NoobFSBlock.GetFreeBlock(NoobFileSystem.mFS.Partition);

            _StartBlock.NextBlock = curb.BlockNumber;
            NoobFSBlock.Write(part, _StartBlock);
            do
            {
                Byte[] arr = new Byte[NoobFSBlock.MaxBlockContentSize];
                index        = Utils.CopyByteToByte(Data, index, arr, 0, arr.Length);
                curb.Used    = true;
                curb.Content = arr;
                if (index != Data.Length)
                {
                    NoobFSBlock b = NoobFSBlock.GetFreeBlock(NoobFileSystem.mFS.Partition);
                    curb.NextBlock   = b.BlockNumber;
                    curb.ContentSize = (uint)arr.Length;
                    NoobFSBlock.Write(NoobFileSystem.mFS.Partition, curb);
                    curb = b;
                }
                else
                {
                    curb.ContentSize = (uint)(Data.Length % arr.Length);
                    NoobFSBlock.Write(NoobFileSystem.mFS.Partition, curb);
                }
            }while (index != Data.Length);
            EditEntryInfo(EntryInfoPosition.DateTimeModified, Environment.DateTime.Now.TimeStamp);
            EditEntryInfo(EntryInfoPosition.DateTimeLastAccess, Environment.DateTime.Now.TimeStamp);
        }