public bool HasAncestor(Folder ancestor) { if (ancestor == null) { throw new ArgumentNullException ("ancestor"); } if (device != ancestor.device) { throw new ArgumentException ("Folders are on different devices"); } bool hasAncestor = false; if (parentId != 0) { if (parentId == ancestor.FolderId) { hasAncestor = true; } else { Folder parent = CreateParentFolder (); hasAncestor = parent.HasAncestor (ancestor); } } return hasAncestor; }
internal static Folder Find(MtpDevice device, uint folderId) { if (device == null) { throw new ArgumentNullException ("device"); } Folder folder = null; IntPtr root = GetFolderList (device.Handle); try { IntPtr ptr = Find (root, folderId); if (ptr != IntPtr.Zero) { FolderStruct folderStruct = (FolderStruct)Marshal.PtrToStructure (ptr, typeof (FolderStruct)); folder = new Folder (folderStruct, device); } } finally { DestroyFolder (root); } return folder; }
public bool InFolder(Folder folder) { return InFolder (folder, false); }
public bool InFolder(Folder folder, bool recursive) { if (folder == null) { return false; } bool is_parent = trackStruct.parent_id == folder.FolderId; if (is_parent || !recursive) { return is_parent; } return Folder.Find (device, trackStruct.parent_id).HasAncestor (folder); }
public void UploadTrack (string path, Track track, Folder folder, ProgressFunction callback) { if (string.IsNullOrEmpty(path)) throw new ArgumentNullException("path"); if (track == null) throw new ArgumentNullException("track"); folder = folder ?? MusicFolder; if (folder != null) { track.trackStruct.parent_id = folder.FolderId; } // We send the trackstruct by ref so that when the file_id gets filled in, our copy is updated Track.SendTrack (Handle, path, ref track.trackStruct, callback, IntPtr.Zero); // LibMtp.GetStorage (Handle, 0); }
public bool InFolder (Folder folder) { return folder != null && trackStruct.parent_id == folder.FolderId; }
public void UploadTrack (string path, Track track, Folder folder) { UploadTrack (path, track, folder, null); }
/// <summary> /// This function scans the top level directories and stores the relevant ones so they are readily /// accessible /// </summary> private void SetDefaultFolders () { List<Folder> folders = GetRootFolders(); foreach (Folder f in folders) { if (f.FolderId == this.device.default_album_folder) albumFolder = f; else if (f.FolderId == device.default_music_folder) { musicFolder = f; // Fix for devices that don't have an explicit playlist folder (BGO #590342) if (device.default_playlist_folder == 0) { playlistFolder = f; } } else if (f.FolderId == device.default_organizer_folder) organizerFolder = f; else if (f.FolderId == device.default_picture_folder) pictureFolder = f; else if (f.FolderId == device.default_playlist_folder) playlistFolder = f; else if (f.FolderId == device.default_text_folder) textFolder = f; else if (f.FolderId == device.default_video_folder) videoFolder = f; else if (f.FolderId == device.default_zencast_folder) podcastFolder = f; } }
public void UploadTrack(string path, Track track, Folder folder) { UploadTrack(path, track, folder, null); }
public List <Folder> GetRootFolders() { return(Folder.GetRootFolders(this)); }
public bool InFolder(Folder folder) { return(folder != null && trackStruct.parent_id == folder.FolderId); }