Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        internal Folder (FolderStruct folder, MtpDevice device)
                    : this (folder.folder_id, folder.parent_id, folder.name, device)
        {

        }
Ejemplo n.º 9
0
 internal Folder(FolderStruct folder, MtpDevice device)
     : this(folder.folder_id, folder.parent_id, folder.name, device)
 {
 }