public FileInterface(ItemInterface item) : base(item.GoogleDriveFile, item.GDrive) { if (item.IsFolder()) { throw new ArgumentException("item represents a folder!", "item"); } }
public DirectoryInterface(ItemInterface item) : base(item.GoogleDriveFile, item.GDrive) { if (!item.IsFolder()) { throw new ArgumentException("item doesn't represent a folder!", "item"); } }
public ItemInterface FindItemFromPath(string fullPath, bool rootFirst = true) { fullPath = PathNormalizer.Normalize(fullPath); string[] items = PathNormalizer.Normalize(fullPath).Split("/"); //Page page = this.RunQueryAsPage($"name = '{items[0]}'"); ItemInterface current = rootFirst ? this.GetFileById("root") : this.GetFileById(this.FindID(items[0]).ID); for (int i = 1; i < items.Length; i++) { string item = items[i]; var result = this.GetDirectoryContent(current.ItemIdentifier); foreach (var resultFile in result.Items) { if (resultFile.Name == item) { current = resultFile; break; } } } string check = current.GetFullName(); bool equal = check == fullPath; if (!equal) { return(null); } return(current); }
public ItemInterface FindParent(ItemInterface child) { if (child.GoogleDriveFile.Parents == null || child.GoogleDriveFile.Parents.Count == 0 || child.GoogleDriveFile.Parents[0] == null) { return(null); } string id = child.GoogleDriveFile.Parents[0]; var parent = GetFileById(id); return(parent); }
public string GetFullName() { if (!String.IsNullOrEmpty(fullName)) { return(fullName); } ItemInterface item = this; while (item != null) { fullName = item.Name + (string.IsNullOrEmpty(fullName) ? String.Empty : "\\") + fullName; item = item.GetParent(); } return(Multisync.App.Util.PathNormalizer.Normalize(fullName)); }
public Page RunQueryAsPage(string query, int pageSize = 100, string pageToken = null) { FileList list = RunQuery(query, pageSize, pageToken); List <ItemInterface> files = new List <ItemInterface>(); foreach (DriveFile dfile in list.Files) { ItemInterface IFile = new ItemInterface(dfile, this); files.Add(IFile); } Page page = new Page(pageToken, list.NextPageToken, files.ToArray()); page.SearchQuery = query; page.MaxAllowedSize = pageSize; return(page); }