Esempio n. 1
0
    public ProjectDirectory CreateDirectory(string name)
    {
        //valid name?
        if (!Helpers.ValidFilename(name)) {
            throw new Exception("Invalid directory name \"" + name + "\"");
        }

        //already exists?
        ProjectDirectory buffer = GetDirectory(name);
        if (FileExists(name)) { return null; }
        if (buffer != null) { return buffer; }

        Monitor.Enter(p_SyncLock);

        //create it
        buffer = new ProjectDirectory(name, Project);
        buffer.AssignNewID();
        buffer.p_ParentID = InstanceID;

        //create the physical directory to associate with this directory
        if (!Directory.Exists(buffer.PhysicalLocation)) {
            Directory.CreateDirectory(buffer.PhysicalLocation);
        }

        //add to the directory children
        Array.Resize(ref p_ChildDirectories, p_ChildDirectories.Length + 1);
        p_ChildDirectories[p_ChildDirectories.Length - 1] = buffer.InstanceID;
        Project.RegisterEntity(buffer, true);

        Monitor.Exit(p_SyncLock);
        Project.Save();
        return buffer;
    }
Esempio n. 2
0
    public ProjectDirectory CreateDirectory(string name)
    {
        //valid name?
        if (!Helpers.ValidFilename(name))
        {
            throw new Exception("Invalid directory name \"" + name + "\"");
        }

        //already exists?
        ProjectDirectory buffer = GetDirectory(name);

        if (FileExists(name))
        {
            return(null);
        }
        if (buffer != null)
        {
            return(buffer);
        }

        Monitor.Enter(p_SyncLock);

        //create it
        buffer = new ProjectDirectory(name, Project);
        buffer.AssignNewID();
        buffer.p_ParentID = InstanceID;

        //create the physical directory to associate with this directory
        if (!Directory.Exists(buffer.PhysicalLocation))
        {
            Directory.CreateDirectory(buffer.PhysicalLocation);
        }

        //add to the directory children
        Array.Resize(ref p_ChildDirectories, p_ChildDirectories.Length + 1);
        p_ChildDirectories[p_ChildDirectories.Length - 1] = buffer.InstanceID;
        Project.RegisterEntity(buffer, true);

        Monitor.Exit(p_SyncLock);
        Project.Save();
        return(buffer);
    }