Beispiel #1
0
 static void Main(string[] args)
 {
     //starts VDisk
     vd = VDisk.Create(1024);
     pt = new PartitionTable(vd);
     //initializes partition
     part = Partitioner.Create(pt, 1024);
     PraxisFormatter.format(part, "system");
     //formats
     praxpart = new PraxisPartition(part);
     PraxisPartitionTable.Add(praxpart);
     //creates file
     Praxis.IO.File.Create("/system/test1.txt", Encoding.UTF8.GetBytes("Hello, World. This is test 1.".PadLeft(1976, 'x')));
     Praxis.IO.File.Create("/system/test2.txt", Encoding.UTF8.GetBytes("Hello, World. This is test 2."));
     Praxis.IO.File.Create("/system/test3.txt", Encoding.UTF8.GetBytes("Hello, World. This is test 3."));
     //writes contents to console
     Console.Write(Encoding.UTF8.GetString(Praxis.IO.File.Read("/system/test1.txt")));//Encoding.UTF8.GetString(Praxis.IO.File.get("system", 0)).Replace(((char)0).ToString(), ""));
     Console.ReadKey();
 }
Beispiel #2
0
        /// <summary>
        /// Creates a new file at the specified path
        /// </summary>
        /// <param name="path">Format is %partname/folder/path/file ex. system/Users/Create.txt</param>
        /// <param name="content"></param>
        public static void Create(string path, byte[] content)
        {
            string[]        paths = path.Split('/');
            PraxisPartition p     = PraxisPartitionTable.Get(paths[1]);

            if (p != null)
            {
                int sectors = p.nextblock();
                for (int i = 2; i < paths.Length; i++)
                {
                    if (paths[i] == "" && i != paths.Length - 1)
                    {
                    }
                    if (i == paths.Length - 1)
                    {
                        p.AddEntry((int)sectors, (int)Quicksilver.Impl.String.GetHashCode(paths[2]), 0xF0);
                        WriteFile(paths[2], (int)sectors, content, p);
                    }
                }
            }
        }
Beispiel #3
0
        /*public static void EditFile(string path, byte[] content)
         * {
         *  string[] paths = path.Split('/');
         *  PraxisPartition p = PraxisPartitionTable.Get(paths[0]);
         *  if (p != null) {
         *      uint sectors = p.nextblock();
         *      for (int i = 1; i < paths.Length; i++) {
         *          if (paths[i] == "" && i != paths.Length - 1) {
         *
         *          }
         *          if (i == paths.Length - 1) {
         *              p.AddEntry((int)sectors, paths[i].GetHashCode(), 0xF0);
         *              WriteFile(paths[1], (int)sectors, content, p);
         *          }
         *      }
         *  }
         * }*/
        public static byte[] Read(string path)
        {
            string[]        paths = path.Split('/');
            PraxisPartition p     = PraxisPartitionTable.Get(paths[1]);

            if (p != null)
            {
                int sectors = 0;
                for (int i = 1; i < paths.Length; i++)
                {
                    if (paths[i] == "" && i != paths.Length - 1)
                    {
                    }
                    if (i == paths.Length - 1)  // && p.doesHaveFile(paths[2].GetHashCode())) {
                    {
                        sectors = p.sectorOfFile((int)Quicksilver.Impl.String.GetHashCode((paths[2])));
                        return(ReadFile(paths[2], sectors, p));
                    }
                }
            }
            return(new byte[1]);
        }
Beispiel #4
0
        public static byte[] get(string partition, int sector)
        {
            var x = PraxisPartitionTable.Get(partition).part.Read(sector);

            return(x);
        }