Exemple #1
0
        public void FileDelete(string path)
        {
            if (!IsPathInCone(path, out string processedPath))
            {
                _basis.FileDelete(path);
                return;
            }

            path = processedPath;
            string rel = path.Substring(_root.FullPath.Length).Trim('/', '\\');

            string[]            parts      = rel.Split('/', '\\');
            FileSystemDirectory currentDir = _root;

            for (int i = 0; i < parts.Length - 1; ++i)
            {
                FileSystemDirectory dir;
                if (!currentDir.Directories.TryGetValue(parts[i], out dir))
                {
                    dir = new FileSystemDirectory(parts[i], Path.Combine(currentDir.FullPath, parts[i]));
                    currentDir.Directories[parts[i]] = dir;
                }

                currentDir = dir;
            }

            currentDir.Files.Remove(parts[parts.Length - 1]);
        }