Exemple #1
0
        public bool Contains(string path)
        {
            if (path.Contains(@"\"))
            {
                path = path.ForwardSlashes();
            }

            if (FileSystemObject.IsPathSystemRooted(path))
            {
                if (path.StartsWith(folderHierarchy.ProjectRoot))
                {
                    path = FileSystemObject.BluntStart(path, folderHierarchy.Root);
                }
                else if (path.StartsWith(folderHierarchy.ServicesRoot))
                {
                    path = FileSystemObject.BluntStart(path, folderHierarchy.Root);

                    if (FileSystemObject.IsPathSystemRooted(path))
                    {
                        path = FileSystemObject.BluntStart(path, folderHierarchy.ServicesRoot);
                    }
                }
            }

            return(folderHierarchy.Index.ContainsKey(path));
        }
Exemple #2
0
        public FileSystemObject this[string path]
        {
            get
            {
                FileSystemObject obj;

                if (path.Contains(@"\"))
                {
                    path = path.ForwardSlashes();
                }

                if (FileSystemObject.IsPathSystemRooted(path))
                {
                    if (path.StartsWith(folderHierarchy.ProjectRoot))
                    {
                        path = FileSystemObject.BluntStart(path, folderHierarchy.Root);
                    }
                    else if (path.StartsWith(folderHierarchy.ServicesRoot))
                    {
                        path = FileSystemObject.BluntStart(path, folderHierarchy.Root);

                        if (FileSystemObject.IsPathSystemRooted(path))
                        {
                            path = FileSystemObject.BluntStart(path, folderHierarchy.ServicesRoot);
                        }
                    }
                }

                obj = folderHierarchy.Index[path];

                DebugUtils.ThrowIf(obj == null, () => new DirectoryNotFoundException(string.Format("Path '{0}' does not exist in virtual file system.", path)));

                return(obj);
            }
        }
Exemple #3
0
        public bool Exists(string path)
        {
            if (FileSystemObject.IsPathSystemRooted(path))
            {
                if (path.StartsWith(folderHierarchy.ProjectRoot))
                {
                    path = FileSystemObject.BluntStart(path, folderHierarchy.Root);
                }
                else if (path.StartsWith(folderHierarchy.ServicesRoot))
                {
                    path = FileSystemObject.BluntStart(path, folderHierarchy.Root);
                }
            }

            return(folderHierarchy.Index.ContainsKey(path));
        }
Exemple #4
0
        public void DeleteFile(string filePath)
        {
            string folderPath;
            string fileName;

            if (FileSystemObject.IsPathSystemRooted(filePath))
            {
                filePath = filePath.ForwardSlashes();

                if (filePath.StartsWith(folderHierarchy.ProjectRoot))
                {
                    filePath = FileSystemObject.BluntStart(filePath, folderHierarchy.Root);
                }
                else if (filePath.StartsWith(folderHierarchy.ServicesRoot))
                {
                    filePath = FileSystemObject.BluntStart(filePath, folderHierarchy.Root);

                    if (FileSystemObject.IsPathSystemRooted(filePath))
                    {
                        filePath = FileSystemObject.BluntStart(filePath, folderHierarchy.ServicesRoot);
                    }
                }
            }

            folderPath = Path.GetDirectoryName(filePath);
            folderPath = folderPath.ForwardSlashes();

            fileName = Path.GetFileName(filePath);

            if (folderHierarchy.FileSystem.Exists(filePath))
            {
                var folder = (Folder)folderHierarchy.FileSystem[folderPath];
                var file   = (File)folderHierarchy.FileSystem[filePath];

                folder.Files.Remove(file);
            }
        }