libgphoto2 photo camera library (libgphoto2) API
Go to the documentation of this file.
30 #ifndef __GPHOTO2_FILESYS_H__
31 #define __GPHOTO2_FILESYS_H__
33 #include <time.h>
34 #include <stdint.h>
37 #include <gphoto2/gphoto2-list.h>
38 #include <gphoto2/gphoto2-file.h>
40 #ifdef __cplusplus
41 extern "C" {
42 #endif /* __cplusplus */
55 typedef enum {
57  GP_FILE_INFO_TYPE = 1 << 0,
58  GP_FILE_INFO_SIZE = 1 << 2,
59  GP_FILE_INFO_WIDTH = 1 << 3,
63  GP_FILE_INFO_MTIME = 1 << 7,
72 typedef enum {
74  GP_FILE_PERM_READ = 1 << 0,
84 typedef enum {
95 typedef struct _CameraFileInfoFile {
97  CameraFileStatus status;
98  uint64_t size;
99  char type[64];
100  uint32_t width;
101  uint32_t height;
103  time_t mtime;
112 typedef struct _CameraFileInfoPreview {
114  CameraFileStatus status;
115  uint64_t size;
116  char type[64];
118  uint32_t width;
119  uint32_t height;
128 typedef struct _CameraFileInfoAudio {
130  CameraFileStatus status;
131  uint64_t size;
132  char type[64];
141 typedef struct _CameraFileInfo {
142  CameraFileInfoPreview preview;
143  CameraFileInfoFile file;
144  CameraFileInfoAudio audio;
153 typedef enum {
175 typedef enum {
189 typedef enum {
201 typedef enum {
216  char basedir[256];
217  char label[256];
218  char description[256];
222  uint64_t capacitykbytes;
223  uint64_t freekbytes;
224  uint64_t freeimages;
239 /* Manual editing */
240 int gp_filesystem_append (CameraFilesystem *fs, const char *folder,
241  const char *filename, GPContext *context);
243  const char *folder, const char *filename,
244  CameraFileInfo info, GPContext *context);
246  const char *folder, const char *filename,
248  CameraFile *file, GPContext *context);
249 int gp_filesystem_delete_file_noop (CameraFilesystem *fs, const char *folder,
250  const char *filename, GPContext *context);
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);
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);
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);
291 /* Files */
292 typedef int (*CameraFilesystemGetFileFunc) (CameraFilesystem *fs,
293  const char *folder,
294  const char *filename,
296  CameraFile *file, void *data,
297  GPContext *context);
298 typedef int (*CameraFilesystemReadFileFunc) (CameraFilesystem *fs,
299  const char *folder,
300  const char *filename,
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);
321 /* Folders */
322 typedef int (*CameraFilesystemPutFileFunc) (CameraFilesystem *fs,
323  const char *folder,
324  const char *filename,
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);
337 typedef int (*CameraFilesystemStorageInfoFunc) (CameraFilesystem *fs,
339  int *nrofstorageinformations,
340  void *data, GPContext *context);
343  CameraStorageInformation **,
344  int *nrofstorageinformations,
345  GPContext *context);
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;
362  /* for later use. Remove one if you add a new function */
363  void *unused[31];
364 };
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);
377 /* For debugging */
380 #ifdef __cplusplus
381 }
382 #endif /* __cplusplus */
384 #endif /* __GPHOTO2_FILESYS_H__ */
uint64_t size
Size of the file.
Definition: gphoto2-filesys.h:98
A fixed RAM storage. (e.g. SDRAM)
Definition: gphoto2-filesys.h:179
Filesystem hierarchy types.
Definition: gphoto2-filesys.h:201
int gp_filesystem_set_info_noop(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo info, GPContext *context)
Store the file information in the virtual fs.
Definition: gphoto2-filesys.c:2329
char type[64]
MIME type of the file.
Definition: gphoto2-filesys.h:99
Definition: gphoto2-list.c:47
CameraFileInfoFields fields
Bitmask containing the set members.
Definition: gphoto2-filesys.h:129
int folder_list_func(CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context)
Definition: template.c:379
int gp_filesystem_free(CameraFilesystem *fs)
Free filesystem struct.
Definition: gphoto2-filesys.c:685
Storage is Ready Only.
Definition: gphoto2-filesys.h:191
int gp_filesystem_get_file(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, GPContext *context)
Get file data from the filesystem.
Definition: gphoto2-filesys.c:1630
uint32_t height
Width of the file.
Definition: gphoto2-filesys.h:101
uint32_t height
Height of the preview.
Definition: gphoto2-filesys.h:119
time_t mtime
Modification time of the file.
Definition: gphoto2-filesys.h:103
Maximum capacity in kbytes.
Definition: gphoto2-filesys.h:164
Unknown storage type.
Definition: gphoto2-filesys.h:176
The filesize is set.
Definition: gphoto2-filesys.h:58
The base directory. Usually / if just 1 storage is attached.
Definition: gphoto2-filesys.h:154
CameraFileInfoFields fields
Bitmask containing the set members.
Definition: gphoto2-filesys.h:96
Definition: gphoto2-filesys.h:76
int gp_filesystem_number(CameraFilesystem *fs, const char *folder, const char *filename, GPContext *context)
Get the index of a file in specified folder.
Definition: gphoto2-filesys.c:1380
File information of a preview file.
Definition: gphoto2-filesys.h:112
A removable RAM storage. (any kind of cards etc)
Definition: gphoto2-filesys.h:180
uint64_t size
Size of the audio file.
Definition: gphoto2-filesys.h:131
int gp_filesystem_delete_file_noop(CameraFilesystem *fs, const char *folder, const char *filename, GPContext *context)
Delete a virtal file from a folder in the filesystem.
Definition: gphoto2-filesys.c:1153
The modification time is set.
Definition: gphoto2-filesys.h:63
struct _CameraFileInfoAudio CameraFileInfoAudio
File information of an audio file.
CameraStorageAccessType access
Access permissions.
Definition: gphoto2-filesys.h:221
int gp_filesystem_name(CameraFilesystem *fs, const char *folder, int filenumber, const char **filename, GPContext *context)
Lookup the filename of an indexed file within a folder.
Definition: gphoto2-filesys.c:1334
int gp_filesystem_set_info(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo info, GPContext *context)
Set information about a file.
Definition: gphoto2-filesys.c:2361
Storage information flags.
Definition: gphoto2-filesys.h:153
The access permissions are set.
Definition: gphoto2-filesys.h:61
Free space in images.
Definition: gphoto2-filesys.h:166
Undefined or unknown filesystem hierarchy.
Definition: gphoto2-filesys.h:202
No fields set.
Definition: gphoto2-filesys.h:56
int gp_filesystem_set_file_noop(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, GPContext *context)
Attach file content to a specified file.
Definition: gphoto2-filesys.c:2194
Possible status values.
Definition: gphoto2-filesys.h:84
CameraStorageInfoFields fields
Bitmask of struct members that are specified.
Definition: gphoto2-filesys.h:215
int file_list_func(CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context)
Definition: template.c:399
int gp_filesystem_list_files(CameraFilesystem *fs, const char *folder, CameraList *list, GPContext *context)
Get the list of files in a folder.
Definition: gphoto2-filesys.c:948
int get_file_func(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *data, GPContext *context)
Definition: template.c:250
uint64_t size
Size of the preview.
Definition: gphoto2-filesys.h:115
Free space in kbytes.
Definition: gphoto2-filesys.h:165
Storage is Read / Write.
Definition: gphoto2-filesys.h:190
File structure.
int gp_filesystem_new(CameraFilesystem **fs)
Create a new filesystem struct.
Definition: gphoto2-filesys.c:654
Access permissions.
Definition: gphoto2-filesys.h:161
uint64_t freeimages
Free space in images (guessed by camera).
Definition: gphoto2-filesys.h:224
int gp_filesystem_get_info(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo *info, GPContext *context)
Get information about the specified file.
Definition: gphoto2-filesys.c:1851
Context callback operation functions.
int gp_filesystem_dump(CameraFilesystem *fs)
Dump the current filesystem.
Definition: gphoto2-filesys.c:801
No permissions.
Definition: gphoto2-filesys.h:73
int gp_filesystem_list_folders(CameraFilesystem *fs, const char *folder, CameraList *list, GPContext *context)
List all subfolders within a filesystem folder.
Definition: gphoto2-filesys.c:1014
struct _CameraFileInfoFile CameraFileInfoFile
File information of a regular file.
CameraStorageType type
Hardware type of the storage.
Definition: gphoto2-filesys.h:219
File information of an audio file.
Definition: gphoto2-filesys.h:128
Definition: gphoto2-filesys.h:86
The MIME type is set.
Definition: gphoto2-filesys.h:57
int gp_filesystem_reset(CameraFilesystem *fs)
Clear the filesystem.
Definition: gphoto2-filesys.c:630
int gp_filesystem_make_dir(CameraFilesystem *fs, const char *folder, const char *name, GPContext *context)
Create a subfolder within a folder.
Definition: gphoto2-filesys.c:1179
Read permissions.
Definition: gphoto2-filesys.h:74
uint64_t capacitykbytes
Total capacity in kbytes.
Definition: gphoto2-filesys.h:222
int gp_filesystem_delete_all(CameraFilesystem *fs, const char *folder, GPContext *context)
Delete all files in specified folder.
Definition: gphoto2-filesys.c:887
uint32_t width
Height of the file.
Definition: gphoto2-filesys.h:100
Abstracted gphoto2 file operations.
DCIM style storage.
Definition: gphoto2-filesys.h:205
Storage access modes.
Definition: gphoto2-filesys.h:189
int gp_filesystem_count(CameraFilesystem *fs, const char *folder, GPContext *context)
Count files a folder of a filesystem.
Definition: gphoto2-filesys.c:1072
File information structure.
Definition: gphoto2-filesys.h:141
CameraStorageFilesystemType fstype
Hierarchy type of the filesystem.
Definition: gphoto2-filesys.h:220
int set_info_func(CameraFilesystem *fs, const char *folder, const char *file, CameraFileInfo info, void *data, GPContext *context)
Definition: template.c:359
Label of the filesystem. Could also be a DOS label.
Definition: gphoto2-filesys.h:157
Filesystem type.
Definition: gphoto2-filesys.h:163
int gp_filesystem_put_file(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, GPContext *context)
Upload a file to a folder on the device filesystem.
Definition: gphoto2-filesys.c:1288
int delete_all_func(CameraFilesystem *fs, const char *folder, void *data, GPContext *context)
Definition: template.c:316
int gp_filesystem_get_folder(CameraFilesystem *fs, const char *filename, char **folder, GPContext *context)
Search a folder that contains a given filename.
Definition: gphoto2-filesys.c:1511
struct _CameraStorageInformation CameraStorageInformation
Storage information structue.
The internal camera filesystem structure.
Definition: gphoto2-filesys.c:242
All possible fields set. Internal.
Definition: gphoto2-filesys.h:64
CameraFileStatus status
Status of the file.
Definition: gphoto2-filesys.h:97
CameraFilePermissions permissions
Permissions of the file.
Definition: gphoto2-filesys.h:102
CameraFileInfoFields fields
Bitmask containing the set members.
Definition: gphoto2-filesys.h:113
The height is set.
Definition: gphoto2-filesys.h:60
Hardware type.
Definition: gphoto2-filesys.h:162
Hardware storage types.
Definition: gphoto2-filesys.h:175
Definition: gphoto2-filesys.h:348
int gp_filesystem_remove_dir(CameraFilesystem *fs, const char *folder, const char *name, GPContext *context)
Remove a subfolder from within a folder.
Definition: gphoto2-filesys.c:1213
Bitmask containing the file permission flags.
Definition: gphoto2-filesys.h:72
Bitmask on what fields are set in the CameraFileInfo structure.
Definition: gphoto2-filesys.h:55
uint32_t width
Width of the preview.
Definition: gphoto2-filesys.h:118
int gp_filesystem_get_storageinfo(CameraFilesystem *fs, CameraStorageInformation **, int *nrofstorageinformations, GPContext *context)
Get the storage information about this filesystem.
Definition: gphoto2-filesys.c:2443
uint64_t freekbytes
Free space in kbytes.
Definition: gphoto2-filesys.h:223
File information of a regular file.
Definition: gphoto2-filesys.h:95
The width is set.
Definition: gphoto2-filesys.h:59
More verbose description.
Definition: gphoto2-filesys.h:160
Definition: gphoto2-filesys.h:85
int gp_filesystem_read_file(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, uint64_t offset, char *buf, uint64_t *size, GPContext *context)
Get partial file data from the filesystem.
Definition: gphoto2-filesys.c:1763
int put_file_func(CameraFilesystem *fs, const char *folder, const char *name, CameraFileType type, CameraFile *file, void *data, GPContext *context)
Definition: template.c:274
Generic flat storage (all in 1 directory).
Definition: gphoto2-filesys.h:203
int gp_filesystem_set_funcs(CameraFilesystem *fs, CameraFilesystemFuncs *funcs, void *data)
Set all filesystem related function pointers.
Definition: gphoto2-filesys.c:1818
Generic tree hierarchy.
Definition: gphoto2-filesys.h:204
int get_info_func(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo *info, void *data, GPContext *context)
Definition: template.c:341
Storage is Ready Only, but allows Delete.
Definition: gphoto2-filesys.h:192
The status is set (downloaded).
Definition: gphoto2-filesys.h:62
The type of view on the specified file.
Definition: gphoto2-file.h:72
struct _CameraFileInfoPreview CameraFileInfoPreview
File information of a preview file.
Storage information structue.
Definition: gphoto2-filesys.h:214
int storage_info_func(CameraFilesystem *fs, CameraStorageInformation **storageinformations, int *nrofstorageinformations, void *data, GPContext *context)
Definition: template.c:420
Definition: gphoto2-context.c:38
Write permissions.
Definition: gphoto2-filesys.h:75
CameraFileStatus status
Status of the preview file.
Definition: gphoto2-filesys.h:130
int gp_filesystem_delete_file(CameraFilesystem *fs, const char *folder, const char *filename, GPContext *context)
Delete a file from a folder.
Definition: gphoto2-filesys.c:1109
A removable ROM storage.
Definition: gphoto2-filesys.h:178
CameraFileStatus status
Status of the preview.
Definition: gphoto2-filesys.h:114
A fixed ROM storage.
Definition: gphoto2-filesys.h:177
struct _CameraFileInfo CameraFileInfo
File information structure.