public ICloudDirectoryEntry GetFolder(string path) { var ph = new PathHelper(path); if (!ph.IsPathRooted()) throw new SharpBoxException(SharpBoxErrorCodes.ErrorInvalidFileOrDirectoryName); return GetFolder(path, null); }
public ICloudDirectoryEntry CreateFolder(string path) { var ph = new PathHelper(path); return ph.IsPathRooted() ? CreateFolderEx(path, GetRoot()) : null; }
private ICloudDirectoryEntry CreateFolderEx(string path, ICloudDirectoryEntry entry) { var ph = new PathHelper(path); var pes = ph.GetPathElements(); foreach (var el in pes) { var cur = GetFolder(el, entry, false); if (cur == null) { var newFolder = CreateFolder(el, entry); if (newFolder == null) throw new SharpBoxException(SharpBoxErrorCodes.ErrorCreateOperationFailed); cur = newFolder; } entry = cur; } return entry; }
public bool CopyFileSystemEntry(string filePath, string newParentPath) { if ((filePath == null) || (newParentPath == null)) throw new SharpBoxException(SharpBoxErrorCodes.ErrorInvalidParameters); var ph = new PathHelper(filePath); var dir = ph.GetDirectoryName(); var file = ph.GetFileName(); if (dir.Length == 0) dir = "/"; var container = GetFolder(dir); var fsEntry = GetFileSystemObject(file, container); var newParent = GetFolder(newParentPath); return CopyFileSystemEntry(fsEntry, newParent); }