private void CheckDirDoesNotExist(MountFilePath file) { if (file.Mount.Exists(file.Path) && file.Mount.IsDir(file.Path)) { throw new IOException(string.Format("Directory {0} already exists", file.GetGlobalPath())); } }
private void CheckEitherDoesNotExist(MountFilePath file) { if (file.Mount.Exists(file.Path)) { throw new IOException(string.Format("Path {0} already exists", file.GetGlobalPath())); } }
private void CheckDirExists(MountFilePath file) { if (!file.Mount.Exists(file.Path) || !file.Mount.IsDir(file.Path)) { throw new FileNotFoundException(string.Format("No such directory: {0}", file.GetGlobalPath())); } }
private void CheckEitherExists(MountFilePath file) { if (!file.Mount.Exists(file.Path)) { throw new FileNotFoundException(string.Format("No such path: {0}", file.GetGlobalPath())); } }
private void CheckWritable(MountFilePath file) { if (file.WritableMount == null) { throw new IOException(string.Format("Access Denied: Mount {0} is read only", file.Mount.Name)); } }
private void CheckConnected(MountFilePath file) { if (!file.LuaMount.Connected) { throw new IOException(string.Format("Access Denied: Mount {0} is disconnected", file.Mount.Name)); } }
private void CheckPathsNotOverlapping(MountFilePath src, MountFilePath dst) { if (src.Mount == dst.Mount) { if (src.Path.IsParentOf(dst.Path) || dst.Path.IsParentOf(src.Path)) { throw new IOException(string.Format("Cannot move or copy path {0} inside itself", src.GetGlobalPath())); } } }
private void CopyRecursive(MountFilePath src, MountFilePath dst) { if (src.Mount.IsDir(src.Path)) { dst.WritableMount.MakeDir(dst.Path); foreach (var file in src.Mount.List(src.Path)) { CopyRecursive( new MountFilePath(src.MountInfo, FilePath.Combine(src.Path, file)), new MountFilePath(dst.MountInfo, FilePath.Combine(dst.Path, file)) ); } } else { using (var reader = src.Mount.OpenForBinaryRead(src.Path)) { using (var writer = dst.WritableMount.OpenForBinaryWrite(dst.Path, false)) { reader.CopyTo(writer); } } } }
private void RecordWrite(MountFilePath file) { file.MountInfo.LastWriteTime = DateTime.Now; }
private void RecordRead(MountFilePath file) { file.MountInfo.LastReadTime = DateTime.Now; }
private void CheckParentDirExists(MountFilePath file) { CheckDirExists(new MountFilePath(file.MountInfo, file.Path.GetDir())); }