public PraxisPartition(Partition par0) { byte[] block0 = par0.Read(0); byte flags0 = block0[36]; if ((flags0 & 0xF0) == 0xF0) { part = par0; entries_in_sector = BitConverter.ToInt32(block0, 42); entries_in_sector = BitConverter.ToInt32(block0, 42); } else throw new Exception("Please format your partition with Praxis"); }
public static void format(Partition p, string label) { byte[] buffer = new byte[2048]; var ms = new MemBlocks(buffer); ms.Write(Encoding.UTF8.GetBytes(label), 0, 32); //under 32 characters, one word. Used in &Label/ ms.Write(BitConverter.GetBytes(0x00000000), 32, 4); //next sector ms.Write(new byte[] { 0xF0, 0x0F }, 36, 2); //is formatted ms.Write(BitConverter.GetBytes(1), 38, 4); //current used sectors ms.Write(BitConverter.GetBytes(0), 42, 4); //number of used entrys //format for files/directory is byte directory,int hash,int block p.Write(0, buffer); }
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(); }