1
/***************************************************************************
4
* Copyright (C) 2006-2007 Alan McGovern
6
* Alan McGovern (alan.mcgovern@gmail.com)
7
****************************************************************************/
9
/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
11
* Permission is hereby granted, free of charge, to any person obtaining a
12
* copy of this software and associated documentation files (the "Software"),
13
* to deal in the Software without restriction, including without limitation
14
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
15
* and/or sell copies of the Software, and to permit persons to whom the
16
* Software is furnished to do so, subject to the following conditions:
18
* The above copyright notice and this permission notice shall be included in
19
* all copies or substantial portions of the Software.
21
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
* DEALINGS IN THE SOFTWARE.
31
using System.Runtime.InteropServices;
37
[DllImport("libmtp.dll")]
38
private static extern IntPtr LIBMTP_new_file_t (); // LIBMTP_file_t *
40
[DllImport("libmtp.dll")]
41
private static extern void LIBMTP_destroy_file_t (ref File file); // LIBMTP_file_t *
43
[DllImport("libmtp.dll")]
44
private static extern string LIBMTP_Get_Filetype_Description (FileType type); // char const *
46
[DllImport("libmtp.dll")]
47
private static extern IntPtr LIBMTP_Get_Filelisting (MtpDeviceHandle handle); // LIBMTP_file_t *
49
[DllImport("libmtp.dll")]
50
private static extern IntPtr LIBMTP_Get_Filelisting_With_Callback (MtpDeviceHandle handle, ProgressFunction function, IntPtr data); // LIBMTP_file_t *
52
[DllImport("libmtp.dll")]
53
private static extern IntPtr LIBMTP_Get_Filemetadata (MtpDeviceHandle handle, uint fileid); // LIBMTP_file_t *
55
[DllImport("libmtp.dll")]
56
private static extern int LIBMTP_Get_File_To_File (MtpDeviceHandle handle, uint fileId, string path, ProgressFunction function, IntPtr data);
58
[DllImport("libmtp.dll")]
59
private static extern void LIBMTP_destroy_filesampledata_t (ref FileSampleData data); // LIBMTP_filesampledata_t *
61
[DllImport("libmtp.dll")]
62
private static extern int LIBMTP_Get_Representative_Sample_Format (MtpDeviceHandle handle, FileType type, IntPtr data_array);
64
[DllImport("libmtp.dll")]
65
private static extern int LIBMTP_Send_Representative_Sample (MtpDeviceHandle handle, uint id, ref FileSampleData sample);
69
[StructLayout(LayoutKind.Sequential)]
70
internal struct FileStruct
74
public int storage_id;
76
[MarshalAs(UnmanagedType.LPStr)]public string filename;
78
public FileType filetype;
79
public IntPtr next; // LIBMTP_file_t*
85
if (next == IntPtr.Zero)
87
return (File)Marshal.PtrToStructure(next, typeof(File));