Exemplo n.º 1
0
        public bool TryFindFile(string virtualPath, out FileExisting file)
        {
            var realPath = CombineDirectory(rootResourceDirectoryPath, virtualPath);

            if (GlobSearch.IsNeeded(virtualPath))
            {
                var fileInfo = GlobSearch.FindFile(realPath);
                if (fileInfo == null)
                {
                    file = null;
                    return(false);
                }
                else
                {
                    file = new FileExisting(this, fileInfo.FullName.RemoveFromBegin(rootResourceDirectoryInfo.FullName.Length), fileInfo.FullName);
                    return(true);
                }
            }
            else
            {
                if (System.IO.File.Exists(realPath))
                {
                    file = new FileExisting(this, virtualPath, realPath);
                    return(true);
                }
            }
            file = null;
            return(false);
        }
Exemplo n.º 2
0
    public static FileInfo FindFile(string fileSearchPattern)
    {
        var globSearch = new GlobSearch(fileSearchPattern);
        var dirPath    = Path.GetDirectoryName(fileSearchPattern);
        var dirInfo    = new DirectoryInfo(dirPath);
        var file       = dirInfo.EnumerateFiles().FirstOrDefault(f => globSearch.Matches(f.FullName));

        return(file);
    }
Exemplo n.º 3
0
        public Texture2D GetTexture2D(string file)
        {
            var search  = new GlobSearch(file);
            var texture = allTexture2Ds.FirstOrDefault(kvp => search.Matches(kvp.Key)).Value;

            if (texture == null)
            {
                var f = this.FileSystem.FindExistingFile(file);
                texture = new Texture2D(f);
                allTexture2Ds[f.VirtualPath] = texture;
            }
            return(texture);
        }
Exemplo n.º 4
0
    //
    // Summary:
    //     Returns an enumerable collection of file system information that matches a specified
    //     search pattern.
    //
    // Parameters:
    //   searchPattern:
    //     The search string to match against the names of directories. This parameter can
    //     contain a combination of valid literal path and wildcard (* and ?) characters
    //     (see Remarks), but doesn't support regular expressions. The default pattern is
    //     "*", which returns all files.
    //
    // Returns:
    //     An enumerable collection of file system information objects that matches searchPattern.
    //
    // Exceptions:
    //   T:System.ArgumentNullException:
    //     searchPattern is null.
    //
    //   T:System.IO.DirectoryNotFoundException:
    //     The path encapsulated in the System.IO.DirectoryInfo object is invalid (for example,
    //     it is on an unmapped drive).
    //
    //   T:System.Security.SecurityException:
    //     The caller does not have the required permission.
    public IEnumerable <FileSystemEntry> EnumerateFileSystemInfos(string searchPattern)
    {
        var g = new GlobSearch(searchPattern);

        return(EnumerateFileSystemInfos().Where(e => g.Matches(e.Name)));
    }
Exemplo n.º 5
0
    //
    // Summary:
    //     Returns an enumerable collection of file information that matches a search pattern.
    //
    // Parameters:
    //   searchPattern:
    //     The search string to match against the names of files. This parameter can contain
    //     a combination of valid literal path and wildcard (* and ?) characters (see Remarks),
    //     but doesn't support regular expressions. The default pattern is "*", which returns
    //     all files.
    //
    // Returns:
    //     An enumerable collection of files that matches searchPattern.
    //
    // Exceptions:
    //   T:System.ArgumentNullException:
    //     searchPattern is null.
    //
    //   T:System.IO.DirectoryNotFoundException:
    //     The path encapsulated in the System.IO.DirectoryInfo object is invalid, (for
    //     example, it is on an unmapped drive).
    //
    //   T:System.Security.SecurityException:
    //     The caller does not have the required permission.
    public IEnumerable <FileEntry> EnumerateFiles(string searchPattern)
    {
        var g = new GlobSearch(searchPattern);

        return(EnumerateFiles().Where(d => g.Matches(d.Name)));
    }
Exemplo n.º 6
0
    //
    // Summary:
    //     Retrieves an array of strongly typed System.IO.FileSystemInfo objects representing
    //     the files and subdirectories that match the specified search criteria.
    //
    // Parameters:
    //   searchPattern:
    //     The search string to match against the names of directories and files. This parameter
    //     can contain a combination of valid literal path and wildcard (* and ?) characters
    //     (see Remarks), but doesn't support regular expressions. The default pattern is
    //     "*", which returns all files.
    //
    // Returns:
    //     An array of strongly typed FileSystemInfo objects matching the search criteria.
    //
    // Exceptions:
    //   T:System.ArgumentException:
    //     searchPattern contains one or more invalid characters defined by the System.IO.Path.GetInvalidPathChars
    //     method.
    //
    //   T:System.ArgumentNullException:
    //     searchPattern is null.
    //
    //   T:System.IO.DirectoryNotFoundException:
    //     The specified path is invalid (for example, it is on an unmapped drive).
    //
    //   T:System.Security.SecurityException:
    //     The caller does not have the required permission.
    public FileSystemEntry[] GetFileSystemInfos(string searchPattern)
    {
        var g = new GlobSearch(searchPattern);

        return(fileSystemEntries.Where(e => g.Matches(e.Name)).ToArray());
    }