Beispiel #1
0
		public override void Close()
		{
			if (this.b == "w")
			{
				MemoryStream memoryStream = new MemoryStream(this.Position);
				for (int i = 0; i < this.Position; i++)
				{
					memoryStream.Write(this.Data[i]);
				}
				this.Data = memoryStream.Data;
				FileSystem.Root.saveFile(this.Data, this.a, CurrentUser.Username);
			}
		}
Beispiel #2
0
 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_);
 }
Beispiel #3
0
 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);
 }