public static void AddItem(INode inode, String itemName, int itemINodeIndex) { var dir = new DirectoryBase(inode); dir.Load(); dir.dir[itemName] = itemINodeIndex; dir.Save(); }
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; }
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(); }
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; }
public static List<KeyValuePair<String, int>> ListItems(INode inode) { var dir = new DirectoryBase(inode); dir.Load(); return dir.List(); }
/// <summary> /// 将 inode 初始化为一个 Directory /// </summary> /// <param name="inode"></param> public static void Initialize(INode inode) { var dir = new DirectoryBase(inode); dir.Save(); }
public static int GetItem(INode inode, String itemName) { var dir = new DirectoryBase(inode); dir.Load(); return dir.Find(itemName); }
public static int Count(INode inode) { var dir = new DirectoryBase(inode); dir.Load(); return dir.dir.Count; }
public static Boolean Contains(INode inode, String name) { var dir = new DirectoryBase(inode); dir.Load(); return dir.Contains(name); }