Ejemplo n.º 1
0
        /// <summary>
        /// Gets the last PulsarFSBlock of the directory
        /// </summary>
        private PulsarFSBlock GetBlockToEdit()
        {
            PulsarFSBlock ret = _StartBlock;

            while (ret.NextBlock != 0)
            {
                ret = PulsarFSBlock.Read(_StartBlock.Partition, _StartBlock.NextBlock);
            }
            if (ret.BlockNumber == _StartBlock.BlockNumber)
            {
                ret                   = PulsarFSBlock.GetFreeBlock(part);
                ret.Used              = true;
                ret.ContentSize       = 0;
                ret.NextBlock         = 0;
                _StartBlock.NextBlock = ret.BlockNumber;
                PulsarFSBlock.Write(part, _StartBlock);
                PulsarFSBlock.Write(part, ret);
            }
            if (part.NewBlockArray(1).Length - ret.ContentSize < 12)
            {
                PulsarFSBlock b = PulsarFSBlock.GetFreeBlock(part);
                if (b == null)
                {
                    return(null);
                }
                ret.NextBlock = b.BlockNumber;
                PulsarFSBlock.Write(part, ret);
                b.Used = true;
                ret    = b;
            }
            return(ret);
        }
Ejemplo n.º 2
0
        /// <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)
            {
                PulsarFileSystem.ClearBlocks(_StartBlock);
                _StartBlock.NextBlock = 0;
                PulsarFSBlock.Write(PulsarFileSystem.mFS.Partition, _StartBlock);
            }
            int           index = 0;
            PulsarFSBlock curb  = PulsarFSBlock.GetFreeBlock(PulsarFileSystem.mFS.Partition);

            _StartBlock.NextBlock = curb.BlockNumber;
            PulsarFSBlock.Write(part, _StartBlock);
            do
            {
                Byte[] arr = new Byte[PulsarFSBlock.MaxBlockContentSize];
                index        = Utils.CopyByteToByte(Data, index, arr, 0, arr.Length);
                curb.Used    = true;
                curb.Content = arr;
                if (index != Data.Length)
                {
                    PulsarFSBlock b = PulsarFSBlock.GetFreeBlock(PulsarFileSystem.mFS.Partition);
                    curb.NextBlock   = b.BlockNumber;
                    curb.ContentSize = (uint)arr.Length;
                    PulsarFSBlock.Write(PulsarFileSystem.mFS.Partition, curb);
                    curb = b;
                }
                else
                {
                    curb.ContentSize = (uint)(Data.Length % arr.Length);
                    PulsarFSBlock.Write(PulsarFileSystem.mFS.Partition, curb);
                }
            }while (index != Data.Length);
            EditEntryInfo(EntryInfoPosition.DateTimeModified, Environment.DateTime.Now.TimeStamp);
            EditEntryInfo(EntryInfoPosition.DateTimeLastAccess, Environment.DateTime.Now.TimeStamp);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new PulsarEntry in the current directory. Uses a random Block.
 /// </summary>
 /// <param name="p">The partition where to create the new PulsarEntry</param>
 /// <param name="name">The new PulsarEntry's name</param>
 protected static PulsarFSBlock CreateEntry(Partition p, String name)
 {
     return(CreateEntry(p, PulsarFSBlock.GetFreeBlock(p), name));
 }