コード例 #1
0
        public FileAttributes GetFileAttributes(string file)
        {
            if (!IsPathInCone(file, out string processedPath))
            {
                return(_basis.GetFileAttributes(file));
            }

            file = processedPath;
            string rel = file.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;
            }

            FileSystemFile targetFile;

            if (!currentDir.Files.TryGetValue(parts[parts.Length - 1], out targetFile))
            {
                throw new FileNotFoundException("File not found", file);
            }

            return(targetFile.Attributes);
        }