libgphoto2 photo camera library (libgphoto2) API 2.5.2

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

gphoto2-filesys.h
Go to the documentation of this file.
1
30 #ifndef __GPHOTO2_FILESYS_H__
31 #define __GPHOTO2_FILESYS_H__
32
33 #include <time.h>
34 #include <stdint.h>
35
36 #include <gphoto2/gphoto2-context.h>
37 #include <gphoto2/gphoto2-list.h>
38 #include <gphoto2/gphoto2-file.h>
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif /* __cplusplus */
43
55 typedef enum {
56 GP_FILE_INFO_NONE = 0,
57 GP_FILE_INFO_TYPE = 1 << 0,
58 GP_FILE_INFO_SIZE = 1 << 2,
59 GP_FILE_INFO_WIDTH = 1 << 3,
60 GP_FILE_INFO_HEIGHT = 1 << 4,
61 GP_FILE_INFO_PERMISSIONS = 1 << 5,
62 GP_FILE_INFO_STATUS = 1 << 6,
63 GP_FILE_INFO_MTIME = 1 << 7,
64 GP_FILE_INFO_ALL = 0xFF
65 } CameraFileInfoFields;
66
72 typedef enum {
73 GP_FILE_PERM_NONE = 0,
74 GP_FILE_PERM_READ = 1 << 0,
75 GP_FILE_PERM_DELETE = 1 << 1,
76 GP_FILE_PERM_ALL = 0xFF
77 } CameraFilePermissions;
78
84 typedef enum {
85 GP_FILE_STATUS_NOT_DOWNLOADED,
86 GP_FILE_STATUS_DOWNLOADED
87 } CameraFileStatus;
88
95 typedef struct _CameraFileInfoFile {
96 CameraFileInfoFields fields;
97 CameraFileStatus status;
98 uint64_t size;
99 char type[64];
100 uint32_t width;
101 uint32_t height;
102 CameraFilePermissions permissions;
103 time_t mtime;
104 } CameraFileInfoFile;
105
112 typedef struct _CameraFileInfoPreview {
113 CameraFileInfoFields fields;
114 CameraFileStatus status;
115 uint64_t size;
116 char type[64];
118 uint32_t width;
119 uint32_t height;
120 } CameraFileInfoPreview;
121
128 typedef struct _CameraFileInfoAudio {
129 CameraFileInfoFields fields;
130 CameraFileStatus status;
131 uint64_t size;
132 char type[64];
133 } CameraFileInfoAudio;
134
141 typedef struct _CameraFileInfo {
142 CameraFileInfoPreview preview;
143 CameraFileInfoFile file;
144 CameraFileInfoAudio audio;
145 } CameraFileInfo;
146
153 typedef enum {
154 GP_STORAGEINFO_BASE = (1<<0),
157 GP_STORAGEINFO_LABEL = (1<<1),
160 GP_STORAGEINFO_DESCRIPTION = (1<<2),
161 GP_STORAGEINFO_ACCESS = (1<<3),
162 GP_STORAGEINFO_STORAGETYPE = (1<<4),
163 GP_STORAGEINFO_FILESYSTEMTYPE = (1<<5),
164 GP_STORAGEINFO_MAXCAPACITY = (1<<6),
165 GP_STORAGEINFO_FREESPACEKBYTES = (1<<7),
166 GP_STORAGEINFO_FREESPACEIMAGES = (1<<8)
167 } CameraStorageInfoFields;
168
175 typedef enum {
176 GP_STORAGEINFO_ST_UNKNOWN = 0,
177 GP_STORAGEINFO_ST_FIXED_ROM = 1,
178 GP_STORAGEINFO_ST_REMOVABLE_ROM = 2,
179 GP_STORAGEINFO_ST_FIXED_RAM = 3,
180 GP_STORAGEINFO_ST_REMOVABLE_RAM = 4
181 } CameraStorageType;
182
189 typedef enum {
190 GP_STORAGEINFO_AC_READWRITE = 0,
191 GP_STORAGEINFO_AC_READONLY = 1,
192 GP_STORAGEINFO_AC_READONLY_WITH_DELETE = 2
193 } CameraStorageAccessType;
194
201 typedef enum {
202 GP_STORAGEINFO_FST_UNDEFINED = 0,
203 GP_STORAGEINFO_FST_GENERICFLAT = 1,
204 GP_STORAGEINFO_FST_GENERICHIERARCHICAL = 2,
205 GP_STORAGEINFO_FST_DCF = 3
206 } CameraStorageFilesystemType;
207
214 typedef struct _CameraStorageInformation {
215 CameraStorageInfoFields fields;
216 char basedir[256];
217 char label[256];
218 char description[256];
219 CameraStorageType type;
220 CameraStorageFilesystemType fstype;
221 CameraStorageAccessType access;
222 uint64_t capacitykbytes;
223 uint64_t freekbytes;
224 uint64_t freeimages;
225 } CameraStorageInformation;
226
234 typedef struct _CameraFilesystem CameraFilesystem;
235
236 int gp_filesystem_new (CameraFilesystem **fs);
237 int gp_filesystem_free (CameraFilesystem *fs);
238
239 /* Manual editing */
240 int gp_filesystem_append (CameraFilesystem *fs, const char *folder,
241 const char *filename, GPContext *context);
242 int gp_filesystem_set_info_noop (CameraFilesystem *fs,
243 const char *folder, const char *filename,
244 CameraFileInfo info, GPContext *context);
245 int gp_filesystem_set_file_noop (CameraFilesystem *fs,
246 const char *folder, const char *filename,
247 CameraFileType type,
248 CameraFile *file, GPContext *context);
249 int gp_filesystem_delete_file_noop (CameraFilesystem *fs, const char *folder,
250 const char *filename, GPContext *context);
251 int gp_filesystem_reset (CameraFilesystem *fs);
252
253 /* Information retrieval */
254 int gp_filesystem_count (CameraFilesystem *fs, const char *folder,
255 GPContext *context);
256 int gp_filesystem_name (CameraFilesystem *fs, const char *folder,
257 int filenumber, const char **filename,
258 GPContext *context);
259 int gp_filesystem_get_folder (CameraFilesystem *fs, const char *filename,
260 char **folder, GPContext *context);
261 int gp_filesystem_number (CameraFilesystem *fs, const char *folder,
262 const char *filename, GPContext *context);
263
264 /* Listings */
265 typedef int (*CameraFilesystemListFunc) (CameraFilesystem *fs,
266 const char *folder, CameraList *list,
267 void *data, GPContext *context);
268 int gp_filesystem_list_files (CameraFilesystem *fs, const char *folder,
269 CameraList *list, GPContext *context);
270 int gp_filesystem_list_folders (CameraFilesystem *fs, const char *folder,
271 CameraList *list, GPContext *context);
272
273 /* File information */
274 typedef int (*CameraFilesystemSetInfoFunc) (CameraFilesystem *fs,
275 const char *folder,
276 const char *filename,
277 CameraFileInfo info, void *data,
278 GPContext *context);
279 typedef int (*CameraFilesystemGetInfoFunc) (CameraFilesystem *fs,
280 const char *folder,
281 const char *filename,
282 CameraFileInfo *info, void *data,
283 GPContext *context);
284 int gp_filesystem_get_info (CameraFilesystem *fs, const char *folder,
285 const char *filename, CameraFileInfo *info,
286 GPContext *context);
287 int gp_filesystem_set_info (CameraFilesystem *fs, const char *folder,
288 const char *filename, CameraFileInfo info,
289 GPContext *context);
290
291 /* Files */
292 typedef int (*CameraFilesystemGetFileFunc) (CameraFilesystem *fs,
293 const char *folder,
294 const char *filename,
295 CameraFileType type,
296 CameraFile *file, void *data,
297 GPContext *context);
298 typedef int (*CameraFilesystemReadFileFunc) (CameraFilesystem *fs,
299 const char *folder,
300 const char *filename,
301 CameraFileType type,
302 uint64_t offset,
303 char *buf,
304 uint64_t *size,
305 void *data,
306 GPContext *context);
307 typedef int (*CameraFilesystemDeleteFileFunc) (CameraFilesystem *fs,
308 const char *folder,
309 const char *filename,
310 void *data, GPContext *context);
311 int gp_filesystem_get_file (CameraFilesystem *fs, const char *folder,
312 const char *filename, CameraFileType type,
313 CameraFile *file, GPContext *context);
314 int gp_filesystem_read_file (CameraFilesystem *fs, const char *folder,
315 const char *filename, CameraFileType type,
316 uint64_t offset, char *buf, uint64_t *size,
317 GPContext *context);
318 int gp_filesystem_delete_file (CameraFilesystem *fs, const char *folder,
319 const char *filename, GPContext *context);
320
321 /* Folders */
322 typedef int (*CameraFilesystemPutFileFunc) (CameraFilesystem *fs,
323 const char *folder,
324 const char *filename,
325 CameraFileType type,
326 CameraFile *file,
327 void *data,
328 GPContext *context);
329 typedef int (*CameraFilesystemDeleteAllFunc) (CameraFilesystem *fs,
330 const char *folder, void *data,
331 GPContext *context);
332 typedef int (*CameraFilesystemDirFunc) (CameraFilesystem *fs,
333 const char *folder,
334 const char *name, void *data,
335 GPContext *context);
336
337 typedef int (*CameraFilesystemStorageInfoFunc) (CameraFilesystem *fs,
338 CameraStorageInformation **,
339 int *nrofstorageinformations,
340 void *data, GPContext *context);
341
342 int gp_filesystem_get_storageinfo (CameraFilesystem *fs,
343 CameraStorageInformation **,
344 int *nrofstorageinformations,
345 GPContext *context);
346
347 typedef struct _CameraFilesystemFuncs CameraFilesystemFuncs;
348 struct _CameraFilesystemFuncs {
349 CameraFilesystemListFunc file_list_func;
350 CameraFilesystemListFunc folder_list_func;
351 CameraFilesystemPutFileFunc put_file_func;
352 CameraFilesystemDeleteAllFunc delete_all_func;
353 CameraFilesystemGetInfoFunc get_info_func;
354 CameraFilesystemSetInfoFunc set_info_func;
355 CameraFilesystemDirFunc make_dir_func;
356 CameraFilesystemDirFunc remove_dir_func;
357 CameraFilesystemGetFileFunc get_file_func;
358 CameraFilesystemReadFileFunc read_file_func;
359 CameraFilesystemDeleteFileFunc del_file_func;
360 CameraFilesystemStorageInfoFunc storage_info_func;
361
362 /* for later use. Remove one if you add a new function */
363 void *unused[31];
364 };
365 int gp_filesystem_set_funcs (CameraFilesystem *fs,
366 CameraFilesystemFuncs *funcs,
367 void *data);
368 int gp_filesystem_put_file (CameraFilesystem *fs, const char *folder, const char *filename,
369 CameraFileType type, CameraFile *file, GPContext *context);
370 int gp_filesystem_delete_all (CameraFilesystem *fs, const char *folder,
371 GPContext *context);
372 int gp_filesystem_make_dir (CameraFilesystem *fs, const char *folder,
373 const char *name, GPContext *context);
374 int gp_filesystem_remove_dir (CameraFilesystem *fs, const char *folder,
375 const char *name, GPContext *context);
376
377 /* For debugging */
378 int gp_filesystem_dump (CameraFilesystem *fs);
379
380 #ifdef __cplusplus
381 }
382 #endif /* __cplusplus */
383
384 #endif /* __GPHOTO2_FILESYS_H__ */