protected internal override FileSystemSessionItem DoNavigate(FileSystemSession session, string path) { if (path.IsNullOrEmpty()) { return(null); } var gds = (GoogleDriveSession)session; var client = gds.Client; var handle = client.GetHandle(path); if (handle == null) { return(null); } var parentPath = GoogleDrivePath.GetParentPath(path); if (!handle.IsFolder) { return(new FileSystemFile(gds, parentPath, handle.Name, handle)); } return(new FileSystemDirectory(gds, parentPath, handle.Name, handle)); }
/// <summary> /// Gets a handle for the specified file or folder. /// </summary> public GoogleDriveHandle GetHandle(string path) { Ensure.NotNull(path, "path"); var segments = GoogleDrivePath.Split(path); if (segments.Length == 0 || path.EqualsOrdIgnoreCase(ROOT)) { var root = GetItemInfoById(ROOT); return(root); } var queue = new Queue <string>(segments); if (IsRoot(segments[0])) { queue.Dequeue(); } var info = GetItemInfo(ROOT, queue); if (info == null) { return(null); } var handle = new GoogleDriveHandle(info); return(handle); }