Exemple #1
0
        /// <summary>
        /// Ensures the specified directory exists
        /// </summary>
        /// <param name="directory">The directory.</param>
        public void CreateDirectory(string directory)
        {
            if (string.IsNullOrEmpty(directory))
            {
                throw new ArgumentNullException("directory");
            }

            directory = Path.GetFullPath(QQnPath.Combine(_directory, directory));             // Gets directory with separator

            if (!directory.StartsWith(_directory))
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Directory {0} is not below root", directory), "directory");
            }

            if (Directory.Exists(directory))
            {
                return;
            }

            CreateDirectory(QQnPath.GetParentDirectory(directory));
            Directory.CreateDirectory(directory);

            DirectoryMapDirectory item = DoGetDirectory(QQnPath.GetRelativePath(directory, _directory));

            using (item.Updater())
            {
                item.Created = true;
            }
        }
Exemple #2
0
        DirectoryMapDirectory DoGetDirectory(string name)
        {
            if (_data.Directories.Contains(name))
            {
                return((DirectoryMapDirectory)_data.Files[name]);
            }

            DirectoryMapDirectory dmf = new DirectoryMapDirectory(name);

            _data.Directories.Add(dmf);
            _data.Dirty = true;
            return(dmf);
        }