Example #1
0
        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;
            }
        }
Example #2
0
        public static void RemoveDirectory(CWDirectory Dir, bool DelFilesOnDisk)
        {
            AssertOpenProject("RemoveDirectory");
            AssertValidDirectory(Dir, "RemoveDirectory");

            g.Main.DeleteDirectory(GetDir(Dir), DelFilesOnDisk);
        }
Example #3
0
 private static void AssertValidDirectory(CWDirectory dir, string caller)
 {
     if (GetDir(dir) == null)
     {
         throw new PluginException("Invalid directory handle.", caller);
     }
 }
Example #4
0
        private static CProject.Directory GetDir(CWDirectory dir)
        {
            foreach (CProject.Directory dirX in g.Project.DirList)
            {
                if (dirX.GetHashCode() == dir.GetHashCode())
                {
                    return(dirX);
                }
            }

            return(null);
        }
Example #5
0
        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);
        }
Example #6
0
        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());
        }
Example #7
0
        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());
        }