internal static List <Folder> GetRootFolders(MtpDevice device) { List <Folder> folders = new List <Folder>(); using (FolderHandle handle = GetFolderList(device.Handle)) { for (IntPtr ptr = handle.DangerousGetHandle(); ptr != IntPtr.Zero;) { FolderStruct folder = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct)); folders.Add(new Folder(folder, device)); ptr = folder.sibling; } return(folders); } }
public Folder AddChild(string name) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); // First create the folder on the device and check for error uint id = CreateFolder (device.Handle, name, FolderId); FolderStruct f = new FolderStruct(); f.folder_id = id; f.parent_id = FolderId; f.name = name; return new Folder(f, device); }
public Folder AddChild(string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } // First create the folder on the device and check for error uint id = CreateFolder(device.Handle, name, FolderId); FolderStruct f = new FolderStruct(); f.folder_id = id; f.parent_id = FolderId; f.name = name; return(new Folder(f, device)); }
internal static List <Folder> GetRootFolders(MtpDevice device) { List <Folder> folders = new List <Folder>(); IntPtr root = GetFolderList(device.Handle); try { for (IntPtr ptr = root; ptr != IntPtr.Zero;) { FolderStruct folder = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct)); folders.Add(new Folder(folder, device)); ptr = folder.sibling; } } finally { // Recursively destroy the folder tree LIBMTP_destroy_folder_t(root); } return(folders); }
public List <Folder> GetChildren() { IntPtr root = GetFolderList(device.Handle); IntPtr ptr = Find(root, folderId); FolderStruct f = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct)); ptr = f.child; List <Folder> folders = new List <Folder>(); while (ptr != IntPtr.Zero) { FolderStruct folder = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct)); folders.Add(new Folder(folder, device)); ptr = folder.sibling; } LIBMTP_destroy_folder_t(root); return(folders); }
public List <Folder> GetChildren() { using (FolderHandle handle = GetFolderList(device.Handle)) { // Find the pointer to the folderstruct representing this folder IntPtr ptr = handle.DangerousGetHandle(); ptr = Find(ptr, folderId); FolderStruct f = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct)); ptr = f.child; List <Folder> folders = new List <Folder>(); while (ptr != IntPtr.Zero) { FolderStruct folder = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct)); folders.Add(new Folder(folder, device)); ptr = folder.sibling; } return(folders); } }
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); }
internal Folder (FolderStruct folder, MtpDevice device) : this (folder.folder_id, folder.parent_id, folder.name, device) { }
internal Folder(FolderStruct folder, MtpDevice device) : this(folder.folder_id, folder.parent_id, folder.name, device) { }