Ejemplo n.º 1
0
        internal void CreateNewDirectory(cFileSystemItem Item)
        {
            cFileFlags Flags = new cFileFlags();

            Flags.Directory = true;
            WorkingDirectory.AddItem(Item);
        }
Ejemplo n.º 2
0
 internal cFileFlags Clone()
 {
     cFileFlags Clone = new cFileFlags();
     Clone.Archive = this.Archive;
     Clone.Directory = this.Directory;
     Clone.Executable = this.Executable;
     Clone.Hidden = this.Hidden;
     Clone.ReadOnly = this.ReadOnly;
     Clone.SystemFile = this.SystemFile;
     return Clone;
 }
Ejemplo n.º 3
0
        internal cFileSystem(DiskType ModeOfDisk, cFloppy FloppyToUse)
        {
            FAT = new cFAT(ModeOfDisk, FloppyToUse);
            cFileFlags RootDirFlags = new cFileFlags();

            RootDirFlags.Directory = true;
            RootDirectory          = new cFileSystemItem("", "", RootDirFlags, true);
            WorkingDirectory       = RootDirectory;
            PathToWorkingDirectory = new List <cFileSystemItem>();
            PathToWorkingDirectory.Add(RootDirectory);
        }
Ejemplo n.º 4
0
        internal cFileFlags Clone()
        {
            cFileFlags Clone = new cFileFlags();

            Clone.Archive    = this.Archive;
            Clone.Directory  = this.Directory;
            Clone.Executable = this.Executable;
            Clone.Hidden     = this.Hidden;
            Clone.ReadOnly   = this.ReadOnly;
            Clone.SystemFile = this.SystemFile;
            return(Clone);
        }
Ejemplo n.º 5
0
 internal cFileSystemItem(string NewName, string NewExtention, cFileFlags NewFlags, bool IsRootDirectory)
 {
     if (NewFlags.Directory)
     {
         Items = new List <cFileSystemItem>();
     }
     else
     {
         File = new cFile();
     }
     Metadata = new cDirectoryEntry(NewName, NewExtention, NewFlags);
     IsRoot   = IsRootDirectory;
 }
Ejemplo n.º 6
0
        internal cDirectoryEntry(string NewName, string NewExtention, cFileFlags NewFlags)
        {
            cDcpuTime Timer = new cDcpuTime();

            //the name/extention strings can be too long - cut them silently, if neccessary or expant them, we want 8 characters long names
            SetName(NewName);
            //and 3 characters long Extensions
            SetExtension(NewExtention);
            this.Flags     = NewFlags;
            CreateDateTime = Timer.ConvertToDcpuTime(DateTime.Now);
            AccessDateTime = Timer.ConvertToDcpuTime(DateTime.Now);
            ModifyDateTime = Timer.ConvertToDcpuTime(DateTime.Now);
            Reserved       = 0;                                                                                         //handling the data, so we hopefully just need to adapt later...
        }
Ejemplo n.º 7
0
 public NewItemWizard(bool IsDirectory, int Endianess)
 {
     InitializeComponent();
     Flags           = new cFileFlags();
     Flags.Directory = IsDirectory;
     if (Flags.Directory)
     {
         gbNewExtension.Visible = false;
         cbExecutable.Visible   = false;
         btReadFile.Visible     = false;
         cbSystemFile.Visible   = false;
         cbArchive.Visible      = false;
     }
     NewItem = new cFileSystemItem("", "", Flags, false);
     Endian  = Endianess;
 }
Ejemplo n.º 8
0
 public NewItemWizard(bool IsDirectory, int Endianess)
 {
     InitializeComponent();
     Flags = new cFileFlags();
     Flags.Directory = IsDirectory;
     if (Flags.Directory)
     {
         gbNewExtension.Visible = false;
         cbExecutable.Visible = false;
         btReadFile.Visible = false;
         cbSystemFile.Visible = false;
         cbArchive.Visible = false;
     }
     NewItem = new cFileSystemItem("", "", Flags, false);
     Endian = Endianess;
 }
Ejemplo n.º 9
0
 internal cFileSystemItem GetItemFromIndex(int Index)
 {
     if (IsDirectory() && (Index - 1 < this.Items.Count))
     {
         if (Index == 0)
         {
             cFileFlags Flags = new cFileFlags();
             Flags.ReadOnly  = true;
             Flags.Directory = true;
             return(new cFileSystemItem("..", "", Flags, false));
         }
         else
         {
             return(Items[Index - 1]);
         }
     }
     else
     {
         return(new cFileSystemItem("", "", new cFileFlags(), false));
     }
 }
Ejemplo n.º 10
0
        internal ushort ConvertToBinary(cFAT FAT, ushort SupSector)
        {
            ushort FirstSector;

            if (IsDirectory())
            {
                ushort[] BinDataTemp = new ushort[(this.Items.Count + 1) * Metadata.GetBinaryEntrySize()];
                ushort[] Temp;
                int      TempIndex = 0;
                FirstSector = FAT.RegisterSectors(this.GetSizeInSectors(FAT.GetSectorSize(), false));
                cFileFlags Flags = new cFileFlags();
                Flags.ReadOnly  = true;
                Flags.Directory = true;
                cFileSystemItem DirUp = new cFileSystemItem("..", "", Flags, false);
                Temp = DirUp.Metadata.GetDirectoryBinData(SupSector, 0);
                for (int i = 0; i < Temp.Length; i++)
                {
                    BinDataTemp[TempIndex] = Temp[i];
                    TempIndex++;
                }
                foreach (cFileSystemItem Item in this.Items)
                {
                    Temp = Item.Metadata.GetDirectoryBinData(Item.ConvertToBinary(FAT, FirstSector), Item.GetSizeInWordsForDirEntry());
                    for (int i = 0; i < Temp.Length; i++)
                    {
                        BinDataTemp[TempIndex] = Temp[i];
                        TempIndex++;
                    }
                }
                FAT.WriteData(BinDataTemp, FirstSector);
            }
            else
            {
                FirstSector = FAT.RegisterSectors(this.GetSizeInSectors(FAT.GetSectorSize(), false));
                FAT.WriteData(this.File.GetData(), FirstSector);
            }
            return(FirstSector);
        }
Ejemplo n.º 11
0
 private bool ConvertEntrys(ushort SectorNumber, cFileSystemItem ItemToFill, uint Size)
 {
     if (ItemToFill.IsDirectory())
     {
         //ignore the first Entry, as it is isn't displayed in the logical structure
         int  SubIndex = ItemToFill.Metadata.GetBinaryEntrySize();
         bool run      = true;
         while (run)
         {
             if (HeaderVerifier.IsValidDirectoryEntry(InputFloppy.Sectors[SectorNumber], SubIndex, SectorNumber, InputFAT))
             {
                 //TODO: Read/write the datetimes
                 cFileFlags Flags = new cFileFlags();
                 Flags.ReadFromBinary((byte)InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 5]);
                 ushort[] Data = new ushort[4];
                 Data[0] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 0];
                 Data[1] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 1];
                 Data[2] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 2];
                 Data[3] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 3];
                 string Name = cFileSigConverter.ConvertToFileName(Data);
                 Data    = new ushort[2];
                 Data[0] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 4];
                 Data[1] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 5];
                 string          Extention = cFileSigConverter.ConvertToFileExtention(Data);
                 cFileSystemItem NewItem   = new cFileSystemItem(Name, Extention, Flags, false);
                 Size = (uint)((uint)InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 13] << 16 |
                               (uint)InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 12]);
                 if (ConvertEntrys(InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 14], NewItem, Size))
                 {
                     ItemToFill.AddItem(NewItem);
                 }
                 SubIndex += ItemToFill.Metadata.GetBinaryEntrySize();
                 if (SubIndex >= InputFAT.GetSectorSize())
                 {
                     SubIndex     = 0;
                     SectorNumber = InputFAT.NextSector(SectorNumber);
                     if (SectorNumber >= 0xFFF0)
                     {
                         run = false;
                     }
                 }
             }
             else
             {
                 run = false;
             }
         }
         return(true);
     }
     else
     {
         List <ushort> Data = new List <ushort>();
         bool          run  = true;
         uint          i    = 0;
         while (run)
         {
             int subIndex = 0;
             while (subIndex < 512 && i < Size)
             {
                 Data.Add(InputFloppy.Sectors[SectorNumber].Memory[subIndex]);
                 i++;
                 subIndex++;
             }
             SectorNumber = InputFAT.NextSector(SectorNumber);
             if (SectorNumber >= 0xFFF0)
             {
                 run = false;
             }
         }
         cFile Newfile = new cFile();
         Newfile.SetFileData(Data);
         ItemToFill.SetFile(Newfile);
         return(true);
     }
 }