/// <summary> /// Creates instance of this class. /// </summary> /// <param name="userFileSystemPath">File or folder path in the user file system.</param> /// <param name="logger">Logger.</param> public VirtualFileSystemItem(string userFileSystemPath, ILogger logger) { if (string.IsNullOrEmpty(userFileSystemPath)) { throw new ArgumentNullException(nameof(userFileSystemPath)); } Logger = logger ?? throw new ArgumentNullException(nameof(logger)); UserFileSystemPath = userFileSystemPath; RemoteStoragePath = Mapping.MapPath(userFileSystemPath); }
/// <summary> /// Creates instance of this class. /// </summary> /// <param name="userFileSystemPath">File or folder path in user file system.</param> /// <param name="logger">Logger.</param> public VfsFileSystemItem(string userFileSystemPath, ILogger logger) { if (string.IsNullOrEmpty(userFileSystemPath)) { throw new ArgumentNullException("userFileSystemPath"); } UserFileSystemPath = userFileSystemPath; RemoteStoragePath = Mapping.MapPath(userFileSystemPath); Logger = logger; }
///<inheritdoc> public async Task MoveToAsync(string userFileSystemNewPath, IOperationContext operationContext, IConfirmationResultContext resultContext) { Logger.LogMessage($"IFileSystemItem.MoveToAsync", UserFileSystemPath, userFileSystemNewPath); string remoteStorageNewPath = Mapping.MapPath(userFileSystemNewPath); if (File.Exists(RemoteStoragePath)) { new FileInfo(RemoteStoragePath).MoveTo(remoteStorageNewPath); } else if (Directory.Exists(RemoteStoragePath)) { new DirectoryInfo(RemoteStoragePath).MoveTo(remoteStorageNewPath); } }
public override async Task <IFileSystemItem> GetFileSystemItemAsync(string path) { string remotePath = Mapping.MapPath(path); if (File.Exists(remotePath)) { FileInfo fileInfo = new FileInfo(remotePath); return(new VfsFile(Mapping.ReverseMapPath(fileInfo.FullName), fileInfo.Attributes, fileInfo.CreationTime, fileInfo.LastWriteTime, fileInfo.LastAccessTime, fileInfo.Length, logger)); } else if (Directory.Exists(remotePath)) { DirectoryInfo dirInfo = new DirectoryInfo(remotePath); return(new VfsFolder(Mapping.ReverseMapPath(dirInfo.FullName), dirInfo.Attributes, dirInfo.CreationTime, dirInfo.LastWriteTime, dirInfo.LastAccessTime, logger)); } return(null); }
public override async Task <IFileSystemItem> GetFileSystemItemAsync(string path, FileSystemItemType itemType) { string remotePath = Mapping.MapPath(path); logger.LogMessage($"{nameof(IEngine)}.{nameof(GetFileSystemItemAsync)}()", path, remotePath); if (File.Exists(remotePath)) { return(new VirtualFile(path, this)); } else if (Directory.Exists(remotePath)) { return(new VirtualFolder(path, this)); } return(null); }
///<inheritdoc> public async Task MoveToAsync(string userFileSystemNewPath, IOperationContext operationContext, IConfirmationResultContext resultContext) { string userFileSystemOldPath = this.UserFileSystemPath; Logger.LogMessage($"{nameof(IFileSystemItem)}.{nameof(MoveToAsync)}()", UserFileSystemPath, userFileSystemNewPath); string remoteStorageNewPath = Mapping.MapPath(userFileSystemNewPath); string remoteStorageOldPath = RemoteStoragePath; if (File.Exists(RemoteStoragePath)) { new FileInfo(RemoteStoragePath).MoveTo(remoteStorageNewPath); } else if (Directory.Exists(RemoteStoragePath)) { new DirectoryInfo(RemoteStoragePath).MoveTo(remoteStorageNewPath); } Logger.LogMessage("Moved item in remote storage succesefully", userFileSystemOldPath, userFileSystemNewPath); }
public async Task GetChildrenAsync(string pattern, IOperationContext operationContext, IFolderListingResultContext resultContext) { IEnumerable <FileSystemInfo> remoteStorageChildren = new DirectoryInfo(Mapping.MapPath(Name)).EnumerateFileSystemInfos(pattern); List <IFileSystemItemBasicInfo> infos = new List <IFileSystemItemBasicInfo>(); foreach (FileSystemInfo remoteStorageItem in remoteStorageChildren) { VfsFileSystemItem info = (VfsFileSystemItem)Mapping.GetUserFileSysteItemBasicInfo(remoteStorageItem); info.Name = Mapping.ReverseMapPath(info.Name); infos.Add(info); } resultContext.ReturnChildren(infos.ToArray(), infos.Count); }