コード例 #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);
            }
        }
コード例 #2
0
ファイル: Folder.cs プロジェクト: gclark916/banshee
 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);
 }
コード例 #3
0
ファイル: Folder.cs プロジェクト: mono-soc-2011/banshee
        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));
        }
コード例 #4
0
ファイル: Folder.cs プロジェクト: mono-soc-2011/banshee
        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);
        }
コード例 #5
0
ファイル: Folder.cs プロジェクト: mono-soc-2011/banshee
        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);
        }
コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #8
0
ファイル: Folder.cs プロジェクト: gclark916/banshee
        internal Folder (FolderStruct folder, MtpDevice device)
                    : this (folder.folder_id, folder.parent_id, folder.name, device)
        {

        }
コード例 #9
0
ファイル: Folder.cs プロジェクト: mono-soc-2011/banshee
 internal Folder(FolderStruct folder, MtpDevice device)
     : this(folder.folder_id, folder.parent_id, folder.name, device)
 {
 }