104 lines
3.2 KiB
C#
104 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using DiscUtils;
|
|
using Tesses.VirtualFilesystem;
|
|
using Tesses.VirtualFilesystem.Filesystems;
|
|
|
|
namespace Tesses.VirtualFilesystem.Filesystems
|
|
{
|
|
public class DiscUtilsFilesystem : SyncFileSystem
|
|
{
|
|
IFileSystem fs;
|
|
public DiscUtilsFilesystem(IFileSystem fs)
|
|
{
|
|
this.fs = fs;
|
|
}
|
|
public override string ConvertPathFromUnixPath(UnixPath path)
|
|
{
|
|
return path.Path.Replace("/","\\");
|
|
}
|
|
public override UnixPath ConvertPathToUnixPath(string path)
|
|
{
|
|
return new UnixPath(path.Replace("\\","/"));
|
|
}
|
|
public override void CreateDirectory(UnixPath directory)
|
|
{
|
|
fs.CreateDirectory(ConvertPathFromUnixPath(directory));
|
|
}
|
|
|
|
public override void DeleteDirectory(UnixPath path)
|
|
{
|
|
fs.DeleteDirectory(ConvertPathFromUnixPath(path));
|
|
}
|
|
|
|
public override void DeleteFile(UnixPath path)
|
|
{
|
|
fs.DeleteFile(ConvertPathFromUnixPath(path));
|
|
}
|
|
|
|
public override bool DirectoryExists(UnixPath path)
|
|
{
|
|
return fs.DirectoryExists(ConvertPathFromUnixPath(path));
|
|
}
|
|
|
|
public override IEnumerable<UnixPath> EnumerateFileSystemEntries(UnixPath path)
|
|
{
|
|
foreach(var item in fs.GetFileSystemEntries(ConvertPathFromUnixPath(path)))
|
|
{
|
|
yield return ConvertPathToUnixPath(item);
|
|
}
|
|
}
|
|
|
|
public override bool FileExists(UnixPath path)
|
|
{
|
|
return fs.FileExists(ConvertPathFromUnixPath(path));
|
|
}
|
|
|
|
public override DateTime GetCreationTime(UnixPath path)
|
|
{
|
|
return fs.GetCreationTime(ConvertPathFromUnixPath(path));
|
|
}
|
|
|
|
public override DateTime GetLastAccessTime(UnixPath path)
|
|
{
|
|
return fs.GetLastAccessTime(ConvertPathFromUnixPath(path));
|
|
}
|
|
|
|
public override DateTime GetLastWriteTime(UnixPath path)
|
|
{
|
|
return fs.GetLastWriteTime(ConvertPathFromUnixPath(path));
|
|
}
|
|
|
|
public override void MoveDirectory(UnixPath src, UnixPath dest)
|
|
{
|
|
fs.MoveDirectory(ConvertPathFromUnixPath(src),ConvertPathFromUnixPath(dest));
|
|
}
|
|
|
|
public override void MoveFile(UnixPath src, UnixPath dest)
|
|
{
|
|
fs.MoveFile(ConvertPathFromUnixPath(src),ConvertPathFromUnixPath(dest));
|
|
}
|
|
|
|
public override Stream Open(UnixPath path, FileMode mode, FileAccess access, FileShare share)
|
|
{
|
|
return fs.OpenFile(ConvertPathFromUnixPath(path),mode,access);
|
|
}
|
|
|
|
public override void SetCreationTime(UnixPath path, DateTime time)
|
|
{
|
|
fs.SetCreationTime(ConvertPathFromUnixPath(path),time);
|
|
}
|
|
|
|
public override void SetLastAccessTime(UnixPath path, DateTime time)
|
|
{
|
|
fs.SetLastAccessTime(ConvertPathFromUnixPath(path),time);
|
|
}
|
|
|
|
public override void SetLastWriteTime(UnixPath path, DateTime time)
|
|
{
|
|
fs.SetLastWriteTime(ConvertPathFromUnixPath(path),time);
|
|
}
|
|
}
|
|
}
|