mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
Move path splitting to VFS.
This commit is contained in:
@@ -96,7 +96,7 @@ namespace RomRepoMgr.Core.Filesystem
|
|||||||
{
|
{
|
||||||
stat = new Stat();
|
stat = new Stat();
|
||||||
|
|
||||||
string[] pieces = path.Split("/", StringSplitOptions.RemoveEmptyEntries);
|
string[] pieces = _vfs.SplitPath(path);
|
||||||
|
|
||||||
if(pieces.Length == 0)
|
if(pieces.Length == 0)
|
||||||
{
|
{
|
||||||
@@ -275,7 +275,7 @@ namespace RomRepoMgr.Core.Filesystem
|
|||||||
|
|
||||||
protected override Errno OnOpenHandle(string path, OpenedPathInfo info)
|
protected override Errno OnOpenHandle(string path, OpenedPathInfo info)
|
||||||
{
|
{
|
||||||
string[] pieces = path.Split("/", StringSplitOptions.RemoveEmptyEntries);
|
string[] pieces = _vfs.SplitPath(path);
|
||||||
|
|
||||||
if(pieces.Length == 0)
|
if(pieces.Length == 0)
|
||||||
return Errno.EISDIR;
|
return Errno.EISDIR;
|
||||||
@@ -520,7 +520,7 @@ namespace RomRepoMgr.Core.Filesystem
|
|||||||
{
|
{
|
||||||
bytesWritten = 0;
|
bytesWritten = 0;
|
||||||
|
|
||||||
string[] pieces = path.Split("/", StringSplitOptions.RemoveEmptyEntries);
|
string[] pieces = _vfs.SplitPath(path);
|
||||||
|
|
||||||
if(pieces.Length == 0)
|
if(pieces.Length == 0)
|
||||||
return Errno.ENODATA;
|
return Errno.ENODATA;
|
||||||
@@ -689,7 +689,7 @@ namespace RomRepoMgr.Core.Filesystem
|
|||||||
{
|
{
|
||||||
names = null;
|
names = null;
|
||||||
|
|
||||||
string[] pieces = path.Split("/", StringSplitOptions.RemoveEmptyEntries);
|
string[] pieces = _vfs.SplitPath(path);
|
||||||
|
|
||||||
if(pieces.Length == 0)
|
if(pieces.Length == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1071,7 +1071,7 @@ namespace RomRepoMgr.Core.Filesystem
|
|||||||
|
|
||||||
protected override Errno OnAccessPath(string path, AccessModes mode)
|
protected override Errno OnAccessPath(string path, AccessModes mode)
|
||||||
{
|
{
|
||||||
string[] pieces = path.Split("/", StringSplitOptions.RemoveEmptyEntries);
|
string[] pieces = _vfs.SplitPath(path);
|
||||||
|
|
||||||
if(pieces.Length == 0)
|
if(pieces.Length == 0)
|
||||||
return mode.HasFlag(AccessModes.W_OK) ? Errno.EROFS : 0;
|
return mode.HasFlag(AccessModes.W_OK) ? Errno.EROFS : 0;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using RomRepoMgr.Database;
|
using RomRepoMgr.Database;
|
||||||
|
|
||||||
@@ -64,5 +65,9 @@ namespace RomRepoMgr.Core.Filesystem
|
|||||||
totalSize = (ulong)ctx.Files.Where(f => f.IsInRepo).Sum(f => (double)f.Size);
|
totalSize = (ulong)ctx.Files.Where(f => f.IsInRepo).Sum(f => (double)f.Size);
|
||||||
files = (ulong)ctx.Files.Count(f => f.IsInRepo);
|
files = (ulong)ctx.Files.Count(f => f.IsInRepo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal string[] SplitPath(string path) =>
|
||||||
|
path.Split(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "\\" : "/",
|
||||||
|
StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user