public static void SetDirectory(CWDirectory Dir) { AssertOpenProject("SetDirectory"); AssertValidDirectory(Dir, "SetDirectory"); CProject.Directory actdir = GetDir(Dir); actdir.name = Dir.name; if (Dir.parent_dir == null) { actdir.parent = null; } else { AssertValidDirectory(Dir.parent_dir, "SetDirectory__SetParentDirectory"); CProject.Directory newparent = GetDir(Dir.parent_dir); if (newparent.GetHashCode() == actdir.GetHashCode()) { throw new PluginException("Setting the parent directory to itself would create a recursive relationship.", "SetDirectory"); } actdir.parent = newparent; } }
public static void RemoveDirectory(CWDirectory Dir, bool DelFilesOnDisk) { AssertOpenProject("RemoveDirectory"); AssertValidDirectory(Dir, "RemoveDirectory"); g.Main.DeleteDirectory(GetDir(Dir), DelFilesOnDisk); }
private static void AssertValidDirectory(CWDirectory dir, string caller) { if (GetDir(dir) == null) { throw new PluginException("Invalid directory handle.", caller); } }
private static CProject.Directory GetDir(CWDirectory dir) { foreach (CProject.Directory dirX in g.Project.DirList) { if (dirX.GetHashCode() == dir.GetHashCode()) { return(dirX); } } return(null); }
public static CWDirectory[] GetDirectories() { AssertOpenProject("GetFiles"); CWDirectory[] outdirs = new CWDirectory[g.Project.DirList.Count]; for (int i = 0; i < g.Project.DirList.Count; i++) { outdirs[i] = GetDirectory((g.Project.DirList[i] as CProject.Directory).GetHashCode()); } return(outdirs); }
public static CWDirectory AddDirectory(string dirname, CWDirectory parent) { AssertOpenProject("AddDirectory"); if (parent != null) { AssertValidDirectory(parent, "AddDirectory__CheckParent"); } CProject.Directory newdir = new CProject.Directory(dirname, ((parent == null) ? null : GetDir(parent))); g.Project.DirList.Add(newdir); return(newdir.ToCWDir()); }
public static CWFile AddFile(string filepath, CWDirectory parent) { AssertOpenProject("AddFile"); if (parent != null) { AssertValidDirectory(parent, "AddFile__CheckParent"); } if (!File.Exists(filepath)) { throw new PluginException(filepath + " does not exist.", "AddFile"); } CProject.File newfile = g.Main.AddExistingFile(filepath, ((parent == null) ? null : GetDir(parent))); return(newfile.ToCWFile()); }