public bool DeleteFolder(WsPath folderPath) { try { return(ExecuteAsync(folderPath, async() => { WsFolder folder = await _apiClient.FindFolder(folderPath.GetFolderPath()); if (folder == null) { return false; } await folder.Delete(); return true; })); } catch (Exception ex) { ShowError("Delete folder error", ex, false); return(false); } }
public IDisposableEnumerable <FindData> GetFolderAllFilesRecursive(WsPath folderPath, int depth = int.MaxValue) { try { return(ExecuteAsync(folderPath, async() => (IDisposableEnumerable <FindData>) new FolderItems(await _apiClient.GetFolderAllFilesRecursive(folderPath.GetFolderPath(), depth)))); } catch (Exception ex) { ShowError("Get all files recursive error", ex, false); return(FolderItems.Empty); } }
public IDisposableEnumerable <FindData> GetFolderItems(WsPath folderPath) { try { _filesPreviewCache.Clear(); return(ExecuteAsync(folderPath, async() => (IDisposableEnumerable <FindData>) new FolderItems(await _apiClient.GetFolderItems(folderPath.GetFolderPath())))); } catch (OperationCanceledException) { return(null); } catch (Exception ex) { ShowError("Get folder content error", ex, false); return(FolderItems.Empty); } }
public FileSystemExitCode MoveOrRenameItem(WsPath sourcePath, WsPath targetPath, bool overwrite, bool sourceIsFolder) { try { return(ExecuteAsync(sourcePath, async() => { WsItem sourceItem; if (sourceIsFolder) { sourceItem = await _apiClient.FindFolder(sourcePath.GetFolderPath()); if (sourceItem != null) { if (overwrite == false) { if (await _apiClient.FindFolder(targetPath.GetFolderPath()) != null) { return FileSystemExitCode.FileExists; // TODO: not work for renaming to existing folder } } } } else { sourceItem = await _apiClient.FindFile(sourcePath.GetFilePath()); if (sourceItem != null) { if (overwrite == false) { if (await _apiClient.FindFile(targetPath.GetFilePath()) != null) { return FileSystemExitCode.FileExists; // TODO: not work for renaming to existing file } } } } if (sourceItem == null) { return FileSystemExitCode.FileNotFound; } if (sourcePath.Parent.Path == targetPath.Parent.Path) { await sourceItem.Rename(targetPath.Name); } else { WsFolder targetFolder = await _apiClient.FindFolder(targetPath.Parent.GetFolderPath()); if (targetFolder == null) { return FileSystemExitCode.FileNotFound; } await sourceItem.Move(targetFolder); } return FileSystemExitCode.OK; })); } catch (Exception ex) { ShowError("Move/rename file/folder error", ex, false); return(FileSystemExitCode.WriteError); } }