Exemplo n.º 1
0
 public FileSystemServer()
 {
     Runtime.UpdateFrequency = UpdateFrequency.Update1;
     try
     {
         StorageReader storage_data = new StorageReader(Storage);
         if (Storage.Length > 0)
         {
             uint num_users = storage_data.ReadUInt32();
             for (uint i = 0U; i != num_users; i++)
             {
                 string user_name = storage_data.ReadString();
                 string password  = storage_data.ReadString();
                 if (!(users.ContainsKey(user_name)))
                 {
                     users.Add(user_name, new User(user_name, password));
                 }
             }
             uint num_files = storage_data.ReadUInt32();
             for (uint i = 0U; i != num_files; i++)
             {
                 string    path             = storage_data.ReadString();
                 string    owner            = storage_data.ReadString();
                 FileFlags read_write_flags = (FileFlags)(storage_data.ReadByte());
                 byte[]    data             = storage_data.ReadByteSequence();
                 files.Add(path, new File(path, owner, (read_write_flags & FileFlags.CanEveryoneRead) == FileFlags.CanEveryoneRead, (read_write_flags & FileFlags.CanEveryoneWrite) == FileFlags.CanEveryoneWrite, data));
             }
         }
     }
     catch (StorageReaderArgumentException e)
     {
         Echo(e.ToString());
     }
     fileSystemListener = IGC.RegisterBroadcastListener(fileSystemServerTag);
 }