public LocalFileSystem(Path basePath) { m_basePath = basePath; if (!System.IO.Directory.Exists(m_basePath.ToString())) System.IO.Directory.CreateDirectory(m_basePath.ToString()); }
public override bool Exists(Path path) { if (System.IO.Directory.Exists(ToLocalPath(path))) return true; return System.IO.File.Exists(ToLocalPath(path)); }
public override void Delete(Path path) { System.IO.File.Delete(ToLocalPath(path)); }
public override FileSystemStream CreateFile(Path path) { return new LocalFileSystemStream(System.IO.File.Create(ToLocalPath(path))); }
public override Directory CreateDirectory(Path path) { var localPath = ToLocalPath(path); System.IO.Directory.CreateDirectory(localPath); return new Directory(this, path); }
private string ToLocalPath(Path path) { return (Path.Combine(m_basePath, path)).ToString(); }
public abstract FileInfo GetFileInfo(Path path);
public override bool Exists(Path path) { return System.IO.File.Exists(ToLocalPath(path)); }
public abstract void Delete(Path path);
public abstract bool Exists(Path path);
public abstract FileSystemStream CreateFile(Path path);
public abstract Directory CreateDirectory(Path path);
public static Path Combine(Path path1, Path path2) { return new Path(System.IO.Path.Combine(path1.ToString(), path2.ToString())); }
public override FileInfo GetFileInfo(Path path) { var fileInfo = new System.IO.FileInfo(ToLocalPath(path)); return new FileInfo(path, fileInfo.Length); }
public abstract FileSystemStream OpenFile(Path path, FileMode mode);
public override FileSystemStream OpenFile(Path path, FileMode mode) { return new LocalFileSystemStream(System.IO.File.Open(ToLocalPath(path), ToLocalFileMode(mode))); }
private string ToLocalPath(Path path) { return (new Uri(m_basePath, path.Uri)).LocalPath; }