예제 #1
0
파일: File.cs 프로젝트: Bargomer/COSMOS-OS
 public static void Save(string name, string text)
 {
     BinaryWriter binaryWriter = new BinaryWriter(new FileStream(name, "w"));
     for (int i = 0; i < text.Length; i++)
     {
         byte i2 = (byte)text[i];
         binaryWriter.BaseStream.Write(i2);
     }
     binaryWriter.BaseStream.Close();
 }
예제 #2
0
파일: GLNFS.cs 프로젝트: Bargomer/COSMOS-OS
 private void b(string A_0)
 {
     if (!this.CanWrite(A_0))
     {
         throw new Exception("Access denied!");
     }
     string text = A_0.Substring(Util.LastIndexOf(A_0, FileSystem.Root.Seperator) + 1);
     A_0 = A_0.Substring(0, Util.LastIndexOf(A_0, FileSystem.Root.Seperator));
     this.a(A_0);
     A_0 = FileSystem.Root.Seperator.ToString() + A_0;
     int num = 2;
     if (Util.Contains(A_0, FileSystem.Root.Seperator))
     {
         num = this.getNodeAddress(A_0, 2);
     }
     byte[] array = new byte[1024];
     this.a.ReadBlock((ulong)num, 2u, array);
     BinaryReader binaryReader = new BinaryReader(new MemoryStream(1024));
     BinaryWriter binaryWriter = new BinaryWriter(new MemoryStream(1024));
     binaryReader.BaseStream.Data = array;
     int num2 = binaryReader.ReadInt32();
     bool flag = false;
     binaryWriter.Write(num2 - 1);
     for (int i = 0; i < num2; i++)
     {
         string data = binaryReader.ReadString();
         int data2 = binaryReader.ReadInt32();
         int data3 = binaryReader.ReadInt32();
         byte data4 = binaryReader.BaseStream.Read();
         byte data5 = binaryReader.BaseStream.Read();
         byte data6 = binaryReader.BaseStream.Read();
         byte data7 = binaryReader.BaseStream.Read();
         string data8 = binaryReader.ReadString();
         string data9 = binaryReader.ReadString();
         int data10 = binaryReader.ReadInt32();
         if (data == text)
         {
             flag = true;
         }
         else
         {
             binaryWriter.Write(data);
             binaryWriter.Write(data2);
             binaryWriter.Write(data3);
             binaryWriter.Write(data4);
             binaryWriter.Write(data5);
             binaryWriter.Write(data6);
             binaryWriter.Write(data7);
             binaryWriter.Write(data8);
             binaryWriter.Write(data9);
             binaryWriter.Write(data10);
         }
     }
     if (flag)
     {
         binaryWriter.BaseStream.Close();
         this.a.WriteBlock((ulong)((long)num), 2u, binaryWriter.BaseStream.Data);
     }
 }
예제 #3
0
파일: GLNFS.cs 프로젝트: Bargomer/COSMOS-OS
 public override void Chmod(string item, string mod)
 {
     if (!this.CanWrite(item))
     {
         throw new Exception("Error: Access Denied!");
     }
     byte data = (byte)Conversions.StringToInt(mod.Substring(0, 1));
     byte data2 = (byte)Conversions.StringToInt(mod.Substring(1, 1));
     byte data3 = (byte)Conversions.StringToInt(mod.Substring(2, 1));
     this.a(item);
     string text = item.Substring(Util.LastIndexOf(item, FileSystem.Root.Seperator) + 1);
     item = item.Substring(0, Util.LastIndexOf(item, FileSystem.Root.Seperator));
     int nodeAddress = this.getNodeAddress(item, 2);
     byte[] array = new byte[1024];
     this.a.ReadBlock((ulong)((long)nodeAddress), 2u, array);
     BinaryReader binaryReader = new BinaryReader(new MemoryStream(1024));
     BinaryWriter binaryWriter = new BinaryWriter(new MemoryStream(1024));
     binaryReader.BaseStream.Data = array;
     int num = binaryReader.ReadInt32();
     binaryWriter.Write(num);
     for (int i = 0; i < num; i++)
     {
         string data4 = binaryReader.ReadString();
         int data5 = binaryReader.ReadInt32();
         int data6 = binaryReader.ReadInt32();
         byte data7 = binaryReader.BaseStream.Read();
         byte data8 = binaryReader.BaseStream.Read();
         byte data9 = binaryReader.BaseStream.Read();
         byte data10 = binaryReader.BaseStream.Read();
         string data11 = binaryReader.ReadString();
         string data12 = binaryReader.ReadString();
         int data13 = binaryReader.ReadInt32();
         if (data4 == text)
         {
             binaryWriter.Write(data4);
             binaryWriter.Write(data5);
             binaryWriter.Write(data6);
             binaryWriter.Write(data7);
             binaryWriter.Write(data);
             binaryWriter.Write(data2);
             binaryWriter.Write(data3);
             binaryWriter.Write(data11);
             binaryWriter.Write(data12);
             binaryWriter.Write(data13);
         }
         else
         {
             binaryWriter.Write(data4);
             binaryWriter.Write(data5);
             binaryWriter.Write(data6);
             binaryWriter.Write(data7);
             binaryWriter.Write(data8);
             binaryWriter.Write(data9);
             binaryWriter.Write(data10);
             binaryWriter.Write(data11);
             binaryWriter.Write(data12);
             binaryWriter.Write(data13);
         }
     }
     binaryWriter.BaseStream.Close();
     this.a.WriteBlock((ulong)((long)nodeAddress), 2u, binaryWriter.BaseStream.Data);
 }
예제 #4
0
파일: GLNFS.cs 프로젝트: Bargomer/COSMOS-OS
 private void a(int A_0)
 {
     byte[] array = new byte[512];
     this.a.ReadBlock(1uL, 1u, array);
     BinaryReader binaryReader = new BinaryReader(new MemoryStream(512));
     binaryReader.BaseStream.Data = array;
     binaryReader.ReadString();
     binaryReader.ReadString();
     BinaryWriter binaryWriter = new BinaryWriter(binaryReader.BaseStream);
     binaryWriter.BaseStream.Position = binaryReader.BaseStream.Position;
     binaryWriter.Write(this.getWriteAddress() + A_0);
     binaryWriter.BaseStream.Close();
     this.a.WriteBlock(1uL, 1u, binaryWriter.BaseStream.Data);
 }
예제 #5
0
파일: GLNFS.cs 프로젝트: Bargomer/COSMOS-OS
 private void a(fsEntry A_0, int A_1)
 {
     byte[] array = new byte[1024];
     this.a.ReadBlock((ulong)((long)A_1), 2u, array);
     BinaryReader binaryReader = new BinaryReader(new MemoryStream(1024));
     binaryReader.BaseStream.Data = array;
     int num = binaryReader.ReadInt32() + 1;
     for (int i = 0; i < num - 1; i++)
     {
         string text = binaryReader.ReadString();
         int num2 = binaryReader.ReadInt32();
         int num3 = binaryReader.ReadInt32();
         byte b = binaryReader.BaseStream.Read();
         byte b2 = binaryReader.BaseStream.Read();
         byte b3 = binaryReader.BaseStream.Read();
         byte b4 = binaryReader.BaseStream.Read();
         string text2 = binaryReader.ReadString();
         string text3 = binaryReader.ReadString();
         int num4 = binaryReader.ReadInt32();
     }
     int position = binaryReader.BaseStream.Position;
     BinaryWriter binaryWriter = new BinaryWriter(new MemoryStream(1024));
     binaryWriter.BaseStream.Data = array;
     binaryWriter.Write(num);
     binaryWriter.BaseStream.Position = position;
     binaryWriter.Write(A_0.Name);
     binaryWriter.Write(A_0.Pointer);
     binaryWriter.Write(A_0.Length);
     binaryWriter.BaseStream.Write(A_0.Attributes);
     binaryWriter.Write(A_0.User);
     binaryWriter.Write(A_0.Group);
     binaryWriter.Write(A_0.Global);
     binaryWriter.Write(global::b.b());
     binaryWriter.Write(A_0.Owner);
     binaryWriter.Write(A_0.Checksum);
     binaryWriter.BaseStream.Close();
     this.a.WriteBlock((ulong)((long)A_1), 2u, binaryWriter.BaseStream.Data);
 }
예제 #6
0
파일: GLNFS.cs 프로젝트: Bargomer/COSMOS-OS
 public void setWriteAddress(int amount)
 {
     byte[] array = new byte[512];
     this.a.ReadBlock(1uL, 1u, array);
     BinaryReader binaryReader = new BinaryReader(new MemoryStream(512));
     binaryReader.BaseStream.Data = array;
     binaryReader.ReadString();
     binaryReader.ReadString();
     BinaryWriter binaryWriter = new BinaryWriter(binaryReader.BaseStream);
     binaryWriter.BaseStream.Position = binaryReader.BaseStream.Position;
     binaryWriter.Write(amount);
     binaryWriter.BaseStream.Close();
     this.a.WriteBlock(1uL, 1u, binaryWriter.BaseStream.Data);
 }
예제 #7
0
파일: GLNFS.cs 프로젝트: Bargomer/COSMOS-OS
 public override void saveFile(byte[] data, string name, string owner)
 {
     name = this.a(name);
     if (Util.Contains(name, FileSystem.Root.Seperator))
     {
         if (!this.CanWrite(name.Substring(0, Util.LastIndexOf(name, FileSystem.Root.Seperator))))
         {
             throw new Exception("Access denied");
         }
     }
     fsEntry fsEntry = new fsEntry();
     fsEntry.Checksum = Hash.getCRC(data);
     fsEntry.Attributes = 1;
     byte[] array = new byte[data.Length + 4];
     MemoryStream memoryStream = new MemoryStream(array.Length);
     BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
     binaryWriter.Write(data.Length);
     int i;
     for (i = 0; i < data.Length; i++)
     {
         binaryWriter.BaseStream.Write(data[i]);
     }
     binaryWriter.BaseStream.Close();
     data = binaryWriter.BaseStream.Data;
     fsEntry.Name = name;
     int j;
     for (j = 0; j < data.Length; j++)
     {
         byte[] array2 = new byte[512];
         for (i = 0; i < 512; i++)
         {
         }
     }
     fsEntry.Length = j;
     fsEntry.Pointer = this.getWriteAddress();
     fsEntry.Attributes = 1;
     fsEntry.Owner = owner;
     int a_ = 2;
     if (Util.Contains(fsEntry.Name, FileSystem.Root.Seperator))
     {
         a_ = this.getNodeAddress(fsEntry.Name.Substring(0, this.a(fsEntry.Name, FileSystem.Root.Seperator)), 2);
     }
     if (this.c(name, FileSystem.Root.Seperator))
     {
         fsEntry.Name = name.Substring(this.a(name, FileSystem.Root.Seperator) + 1);
     }
     string[] array3 = this.ListFiles(name.Substring(0, this.a(name, FileSystem.Root.Seperator)));
     i = 0;
     while (i < array3.Length)
     {
         if (array3[i] == name.Substring(Util.LastIndexOf(name, FileSystem.Root.Seperator) + 1))
         {
             if (fsEntry.Length * 512 <= j)
             {
                 fsEntry = this.readFromNode(name);
                 this.b(name);
                 if (data.Length < 512)
                 {
                     memoryStream = new MemoryStream(512);
                     for (int k = 0; k < data.Length; k++)
                     {
                         memoryStream.Write(data[k]);
                     }
                     this.a.WriteBlock((ulong)((long)fsEntry.Pointer), 1u, memoryStream.Data);
                     this.a(fsEntry, a_);
                 }
                 else
                 {
                     int l = 0;
                     int num = fsEntry.Pointer;
                     while (l < data.Length)
                     {
                         byte[] array2 = new byte[512];
                         for (int k = 0; k < 512; k++)
                         {
                             array2[k] = data[l];
                             l++;
                         }
                         this.a.WriteBlock((ulong)((long)num), 1u, array2);
                         num++;
                     }
                     this.a(fsEntry, a_);
                 }
                 return;
             }
             fsEntry.Owner = this.readFromNode(name).Owner;
             fsEntry.Group = this.readFromNode(name).Group;
             fsEntry.Global = this.readFromNode(name).Global;
             fsEntry.User = this.readFromNode(name).User;
             this.b(name);
             break;
         }
         else
         {
             i++;
         }
     }
     if (data.Length < 512)
     {
         memoryStream = new MemoryStream(512);
         for (i = 0; i < data.Length; i++)
         {
             memoryStream.Write(data[i]);
         }
         this.a.WriteBlock((ulong)((long)fsEntry.Pointer), 1u, memoryStream.Data);
         this.a(fsEntry, a_);
         this.a(j);
         return;
     }
     int m = 0;
     int num2 = this.getWriteAddress();
     this.a(j);
     while (m < data.Length)
     {
         byte[] array2 = new byte[512];
         for (i = 0; i < 512; i++)
         {
             array2[i] = data[m];
             m++;
         }
         this.a.WriteBlock((ulong)((long)num2), 1u, array2);
         num2++;
     }
     this.a(fsEntry, a_);
 }
예제 #8
0
파일: GLNFS.cs 프로젝트: Bargomer/COSMOS-OS
 public void Format(string VolumeLABEL)
 {
     byte[] array = new byte[512];
     MemoryStream memoryStream = new MemoryStream(512);
     for (int i = 0; i < 512; i++)
     {
         array[i] = 0;
     }
     for (int j = 0; j < 100; j++)
     {
         this.a.WriteBlock((ulong)((long)j), 1u, array);
     }
     memoryStream.Data = array;
     BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
     binaryWriter.Write("GFS SC");
     binaryWriter.Write(VolumeLABEL);
     binaryWriter.Write(4);
     binaryWriter.BaseStream.Close();
     this.a.WriteBlock(1uL, 1u, binaryWriter.BaseStream.Data);
 }