Exemplo n.º 1
0
        public string ReadFile(string filename)
        {
            Sys.Filesystem.Listing.File file = GetFile(filename);
            if (file == null)
            {
                return(null);
            }
            Sys.Filesystem.FAT.FatStream stream =
                new Sys.Filesystem.FAT.FatStream((Sys.Filesystem.FAT.Listing.FatFile)file);
            byte[] data = new byte[file.Size];
            stream.Read(data, 0, (int)file.Size);
            string text = Encoding.ASCII.GetString(data);

            return(text);
        }
Exemplo n.º 2
0
 public void Mount()
 {
     // Detect a partition
     if (this.vlevel > 0)
     {
         Out.printf("+-- Mounting...\n");
     }
     if (this.vlevel == 2)
     {
         Out.printf("|   +-- Checking for partitions...\n");
     }
     if (BlockDevice.Devices.Count > 0)
     {
         for (int i = 0; i < BlockDevice.Devices.Count; i++)
         {
             var xDevice = BlockDevice.Devices[i];
             if (xDevice is Partition)
             {
                 if (this.vlevel == 2)
                 {
                     Out.printf("|   |   +-- Partition found!\n");
                 }
                 this.xPartition = (Partition)xDevice;
                 this.xFS        = new Cosmos.System.Filesystem.FAT.FatFileSystem(this.xPartition);
                 if (this.vlevel > 0)
                 {
                     Out.printf("|   +-- Mapping filesystem...\n");
                 }
                 Sys.Filesystem.FileSystem.AddMapping("WITCHOS", this.xFS);
                 this.xListing = xFS.GetRoot();
                 if (this.vlevel == 2)
                 {
                     Out.printf("|   +-- Checking for root file...\n");
                 }
                 for (int j = 0; j < xListing.Count; j++)
                 {
                     var xItem = xListing[j];
                     if (xItem is Sys.Filesystem.Listing.File && xItem.Name == "WOSFSROOT")
                     {
                         if (this.vlevel == 2)
                         {
                             Out.printf("|   |   +-- Root file found!\n");
                         }
                         this.xRootFile = (Cosmos.System.Filesystem.FAT.Listing.FatFile) this.xListing[j];
                         break;
                     }
                 }
                 if (this.vlevel == 2)
                 {
                     try
                     {
                         Out.printf("|   |   +-- Reading root file...\n");
                         if (this.xRootFile != null)
                         {
                             var xStream = new Sys.Filesystem.FAT.FatStream(this.xRootFile);
                             var xData   = new byte[this.xRootFile.Size];
                             xStream.Read(xData, 0, (int)this.xRootFile.Size);
                             var xText = Encoding.ASCII.GetString(xData);
                             Out.printf(xText);
                         }
                         else
                         {
                             Out.printf("|   |   |   +-- Root file not found!\n");
                         }
                     }
                     catch (Exception ex)
                     {
                         Out.printf("Error: %s\n", ex.Message);
                     }
                 }
                 else
                 {
                     try
                     {
                         if (this.xRootFile != null)
                         {
                             var xStream = new Sys.Filesystem.FAT.FatStream(this.xRootFile);
                             var xData   = new byte[this.xRootFile.Size];
                             xStream.Read(xData, 0, (int)this.xRootFile.Size);
                             var xText = Encoding.ASCII.GetString(xData);
                         }
                     }
                     catch (Exception ex)
                     {
                         //dewitcher.Core.Bluescreen.Init(ex, false);
                         Out.printf("Error while reading root file: %s\n", ex.Message);
                     }
                 }
             }
         }
     }
 }