mirror of
https://github.com/kwsch/pkNX.git
synced 2026-09-30 13:16:58 -05:00
Improve VFS API
Rename to match actual behaviour and add throw if invalid
This commit is contained in:
@@ -42,17 +42,17 @@ public FileSystemPath GetVirtualDirectoryPath(string physicalPath)
|
||||
return FileSystemPath.Parse(virtualPath);
|
||||
}
|
||||
|
||||
public IEnumerable<FileSystemPath> GetEntityPaths(FileSystemPath path, Func<FileSystemPath, bool>? filter = null)
|
||||
public IEnumerable<FileSystemPath> GetEntitiesInDirectory(FileSystemPath directory, Func<FileSystemPath, bool>? filter = null)
|
||||
{
|
||||
return GetDirectoryPaths(path, filter).Concat(GetFilePaths(path, filter));
|
||||
return GetDirectoriesInDirectory(directory, filter).Concat(GetFilesInDirectory(directory, filter));
|
||||
}
|
||||
|
||||
public IEnumerable<FileSystemPath> GetDirectoryPaths(FileSystemPath path, Func<FileSystemPath, bool>? filter = null)
|
||||
public IEnumerable<FileSystemPath> GetDirectoriesInDirectory(FileSystemPath directory, Func<FileSystemPath, bool>? filter = null)
|
||||
{
|
||||
if (!path.IsDirectory)
|
||||
throw new ArgumentException("This FileSystemPath is not a directory.", nameof(path));
|
||||
if (!directory.IsDirectory)
|
||||
throw new ArgumentException("This FileSystemPath is not a directory.", nameof(directory));
|
||||
|
||||
var physicalPaths = Directory.GetDirectories(GetPhysicalPath(path));
|
||||
var physicalPaths = Directory.GetDirectories(GetPhysicalPath(directory));
|
||||
var virtualPaths = physicalPaths.Select(GetVirtualDirectoryPath);
|
||||
|
||||
if (filter == null)
|
||||
@@ -61,12 +61,12 @@ public IEnumerable<FileSystemPath> GetDirectoryPaths(FileSystemPath path, Func<F
|
||||
return virtualPaths.Where(filter);
|
||||
}
|
||||
|
||||
public IEnumerable<FileSystemPath> GetFilePaths(FileSystemPath path, Func<FileSystemPath, bool>? filter = null)
|
||||
public IEnumerable<FileSystemPath> GetFilesInDirectory(FileSystemPath directory, Func<FileSystemPath, bool>? filter = null)
|
||||
{
|
||||
if (!path.IsDirectory)
|
||||
throw new ArgumentException("The specified path is not a directory.", nameof(path));
|
||||
if (!directory.IsDirectory)
|
||||
throw new ArgumentException("The specified path is not a directory.", nameof(directory));
|
||||
|
||||
var physicalPaths = Directory.GetFiles(GetPhysicalPath(path));
|
||||
var physicalPaths = Directory.GetFiles(GetPhysicalPath(directory));
|
||||
var virtualPaths = physicalPaths.Select(GetVirtualFilePath);
|
||||
|
||||
if (filter == null)
|
||||
|
||||
Reference in New Issue
Block a user