Пример #1
0
 public bool CanRead(Session sess, File item)
 {
     if (sess.CurrentUser == this.RootUser)
     {
         return true;
     }
     return item.CanView(sess.CurrentUser);
 }
Пример #2
0
        public ComputerSystem()
        {
            this.RootUser = new User(this, "SYSTEM");
            this.Users.Add(this.RootUser);

            this.RootFile = new File("Root", 0, this.RootUser);
            this.RootFile.Directory = true;
            this.GenerateUsers();

            FileSystemGenerator.GenerateBasicFilesystem(this, new Session(this.RootUser));
        }
Пример #3
0
        public ComputerSystem(Network parent)
        {
            this.Parent = parent;
            if (this.Parent.DomainControler != null)
            {
                this.Standalone = false;
            }
            else
            {
                this.GenerateUsers();
            }

            this.RootUser = new User(this, "SYSTEM");
            this.Users.Add(this.RootUser);

            this.RootFile = new File("Root", 0, this.RootUser);
            this.RootFile.Directory = true;
            FileSystemGenerator.GenerateBasicFilesystem(this, new Session(this.RootUser));
        }
Пример #4
0
 public void FSCreateFile(string path, string name, int size, Session sess)
 {
     File currentDirectory = this.FSGetDirectory(path, sess);
     File newFile = new File(name, size, sess.CurrentUser);
     currentDirectory.Children.Add(newFile);
 }
Пример #5
0
 public File GetDirectory(string name, bool create, User owner)
 {
     foreach (File item in this.Children)
     {
         if (item.Name == name && item.Directory)
         {
             return item;
         }
     }
     if (create)
     {
         File newFile = new File(name, 0, owner);
         newFile.Directory = true;
         this.Children.Add(newFile);
         return newFile;
     }
     else
     {
         return null;
     }
 }
Пример #6
0
 public void FSSweepPremissions(File path, bool subdirectorys, UserGroup toJoin, FilePremission newPremission, Session sess)
 {
     foreach (File item in path.Children)
     {
         if (item.Directory)
         {
             if (!subdirectorys)
             {
                 continue;
             }
             this.FSSetPremission(item, toJoin, newPremission, sess);
             this.FSSweepPremissions(item, subdirectorys, toJoin, newPremission, sess);
         }
         else
         {
             this.FSSetPremission(item, toJoin, newPremission, sess);
         }
     }
 }
Пример #7
0
 public void FSSetPremission(File item, UserGroup toJoin, FilePremission newPremission, Session sess)
 {
     if (item.CanView(sess.CurrentUser))
     {
         if (item.GroupPremitions.ContainsKey(toJoin))
         {
             item.GroupPremitions[toJoin] = newPremission;
         }
         else
         {
             item.GroupPremitions.Add(toJoin, newPremission);
         }
     }
 }