Exemple #1
0
 public static void AddItem(INode inode, String itemName, int itemINodeIndex)
 {
     var dir = new DirectoryBase(inode);
     dir.Load();
     dir.dir[itemName] = itemINodeIndex;
     dir.Save();
 }
Exemple #2
0
        public Directory(string path)
        {
            if (!path.EndsWith("\\"))
            {
                path += "\\";
            }
            this.path = path;

            DirectoryBase root = new DirectoryBase(Disk.iNodes[0]);
            root.Load();

            var pathCom = path.Split('\\');
            var node = root;

            exist = true;

            for (var i = 1; i < pathCom.Length - 1; ++i)
            {
                if (node.Contains(pathCom[i]) && (Disk.iNodes[node.Find(pathCom[i])].attribute & System.IO.FileAttributes.Directory) != 0)
                {
                    node = new DirectoryBase(Disk.iNodes[node.Find(pathCom[i])]);
                    node.Load();
                }
                else
                {
                    exist = false;
                    break;
                }
            }

            inodeIndex = node.inode.index;
        }
Exemple #3
0
 public static void DeleteItem(INode inode, String itemName)
 {
     var dir = new DirectoryBase(inode);
     dir.Load();
     if (!dir.Contains(itemName))
     {
         throw new System.IO.FileNotFoundException();
     }
     dir.dir.Remove(itemName);
     dir.Save();
 }
Exemple #4
0
 public static void RenameItem(INode inode, String itemOldName, String itemNewName)
 {
     var dir = new DirectoryBase(inode);
     dir.Load();
     if (!dir.Contains(itemOldName))
     {
         throw new System.IO.FileNotFoundException();
     }
     if (dir.Contains(itemNewName))
     {
         throw new System.IO.IOException();
     }
     var inodeIndex = dir.dir[itemOldName];
     dir.dir.Remove(itemOldName);
     dir.dir[itemNewName] = inodeIndex;
 }
Exemple #5
0
 public static List<KeyValuePair<String, int>> ListItems(INode inode)
 {
     var dir = new DirectoryBase(inode);
     dir.Load();
     return dir.List();
 }
Exemple #6
0
 /// <summary>
 /// 将 inode 初始化为一个 Directory
 /// </summary>
 /// <param name="inode"></param>
 public static void Initialize(INode inode)
 {
     var dir = new DirectoryBase(inode);
     dir.Save();
 }
Exemple #7
0
 public static int GetItem(INode inode, String itemName)
 {
     var dir = new DirectoryBase(inode);
     dir.Load();
     return dir.Find(itemName);
 }
Exemple #8
0
 public static int Count(INode inode)
 {
     var dir = new DirectoryBase(inode);
     dir.Load();
     return dir.dir.Count;
 }
Exemple #9
0
 public static Boolean Contains(INode inode, String name)
 {
     var dir = new DirectoryBase(inode);
     dir.Load();
     return dir.Contains(name);
 }