libgphoto2 photo camera library (libgphoto2) API  2.5.0
gphoto2-filesys.h
Go to the documentation of this file.
00001 
00030 #ifndef __GPHOTO2_FILESYS_H__
00031 #define __GPHOTO2_FILESYS_H__
00032 
00033 #include <time.h>
00034 #include <stdint.h>
00035 
00036 #include <gphoto2/gphoto2-context.h>
00037 #include <gphoto2/gphoto2-list.h>
00038 #include <gphoto2/gphoto2-file.h>
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif /* __cplusplus */
00043 
00055 typedef enum {
00056         GP_FILE_INFO_NONE            = 0,       
00057         GP_FILE_INFO_TYPE            = 1 << 0,  
00058         GP_FILE_INFO_SIZE            = 1 << 2,  
00059         GP_FILE_INFO_WIDTH           = 1 << 3,  
00060         GP_FILE_INFO_HEIGHT          = 1 << 4,  
00061         GP_FILE_INFO_PERMISSIONS     = 1 << 5,  
00062         GP_FILE_INFO_STATUS          = 1 << 6,  
00063         GP_FILE_INFO_MTIME           = 1 << 7,  
00064         GP_FILE_INFO_ALL             = 0xFF     
00065 } CameraFileInfoFields;
00066 
00072 typedef enum {
00073         GP_FILE_PERM_NONE       = 0,            
00074         GP_FILE_PERM_READ       = 1 << 0,       
00075         GP_FILE_PERM_DELETE     = 1 << 1,       
00076         GP_FILE_PERM_ALL        = 0xFF          
00077 } CameraFilePermissions;
00078 
00084 typedef enum {
00085         GP_FILE_STATUS_NOT_DOWNLOADED,  
00086         GP_FILE_STATUS_DOWNLOADED       
00087 } CameraFileStatus;
00088 
00095 typedef struct _CameraFileInfoFile {
00096         CameraFileInfoFields fields;    
00097         CameraFileStatus status;        
00098         uint64_t size;                  
00099         char type[64];                  
00100         uint32_t width;                 
00101         uint32_t height;                
00102         CameraFilePermissions permissions;
00103         time_t mtime;                   
00104 } CameraFileInfoFile;
00105 
00112 typedef struct _CameraFileInfoPreview {
00113         CameraFileInfoFields fields;    
00114         CameraFileStatus status;        
00115         uint64_t size;                  
00116         char type[64];                  
00118         uint32_t width;                 
00119         uint32_t height;                
00120 } CameraFileInfoPreview;
00121 
00128 typedef struct _CameraFileInfoAudio {
00129         CameraFileInfoFields fields;    
00130         CameraFileStatus status;        
00131         uint64_t size;          
00132         char type[64];                  
00133 } CameraFileInfoAudio;
00134 
00141 typedef struct _CameraFileInfo {
00142         CameraFileInfoPreview preview;
00143         CameraFileInfoFile    file;
00144         CameraFileInfoAudio   audio;
00145 } CameraFileInfo;
00146 
00153 typedef enum {
00154         GP_STORAGEINFO_BASE             = (1<<0),       
00157         GP_STORAGEINFO_LABEL            = (1<<1),       
00160         GP_STORAGEINFO_DESCRIPTION      = (1<<2),       
00161         GP_STORAGEINFO_ACCESS           = (1<<3),       
00162         GP_STORAGEINFO_STORAGETYPE      = (1<<4),       
00163         GP_STORAGEINFO_FILESYSTEMTYPE   = (1<<5),       
00164         GP_STORAGEINFO_MAXCAPACITY      = (1<<6),       
00165         GP_STORAGEINFO_FREESPACEKBYTES  = (1<<7),       
00166         GP_STORAGEINFO_FREESPACEIMAGES  = (1<<8)        
00167 } CameraStorageInfoFields;
00168 
00175 typedef enum {
00176         GP_STORAGEINFO_ST_UNKNOWN       = 0,    
00177         GP_STORAGEINFO_ST_FIXED_ROM     = 1,    
00178         GP_STORAGEINFO_ST_REMOVABLE_ROM = 2,    
00179         GP_STORAGEINFO_ST_FIXED_RAM     = 3,    
00180         GP_STORAGEINFO_ST_REMOVABLE_RAM = 4     
00181 } CameraStorageType;
00182 
00189 typedef enum {
00190         GP_STORAGEINFO_AC_READWRITE             = 0,    
00191         GP_STORAGEINFO_AC_READONLY              = 1,    
00192         GP_STORAGEINFO_AC_READONLY_WITH_DELETE  = 2     
00193 } CameraStorageAccessType;
00194 
00201 typedef enum {
00202         GP_STORAGEINFO_FST_UNDEFINED            = 0,    
00203         GP_STORAGEINFO_FST_GENERICFLAT          = 1,    
00204         GP_STORAGEINFO_FST_GENERICHIERARCHICAL  = 2,    
00205         GP_STORAGEINFO_FST_DCF                  = 3     
00206 } CameraStorageFilesystemType;
00207 
00214 typedef struct _CameraStorageInformation {
00215         CameraStorageInfoFields         fields; 
00216         char                            basedir[256];   
00217         char                            label[256];     
00218         char                            description[256];
00219         CameraStorageType               type;           
00220         CameraStorageFilesystemType     fstype;         
00221         CameraStorageAccessType         access;         
00222         uint64_t                        capacitykbytes; 
00223         uint64_t                        freekbytes;     
00224         uint64_t                        freeimages;     
00225 } CameraStorageInformation;
00226 
00234 typedef struct _CameraFilesystem CameraFilesystem;
00235 
00236 int gp_filesystem_new    (CameraFilesystem **fs);
00237 int gp_filesystem_free   (CameraFilesystem *fs);
00238 
00239 /* Manual editing */
00240 int gp_filesystem_append           (CameraFilesystem *fs, const char *folder,
00241                                     const char *filename, GPContext *context);
00242 int gp_filesystem_set_info_noop    (CameraFilesystem *fs,
00243                                     const char *folder, const char *filename,
00244                                     CameraFileInfo info, GPContext *context);
00245 int gp_filesystem_set_file_noop    (CameraFilesystem *fs,
00246                                     const char *folder, const char *filename,
00247                                     CameraFileType type,
00248                                     CameraFile *file, GPContext *context);
00249 int gp_filesystem_delete_file_noop (CameraFilesystem *fs, const char *folder,
00250                                     const char *filename, GPContext *context);
00251 int gp_filesystem_reset            (CameraFilesystem *fs);
00252 
00253 /* Information retrieval */
00254 int gp_filesystem_count        (CameraFilesystem *fs, const char *folder,
00255                                 GPContext *context);
00256 int gp_filesystem_name         (CameraFilesystem *fs, const char *folder,
00257                                 int filenumber, const char **filename,
00258                                 GPContext *context);
00259 int gp_filesystem_get_folder   (CameraFilesystem *fs, const char *filename,
00260                                 char **folder, GPContext *context);
00261 int gp_filesystem_number       (CameraFilesystem *fs, const char *folder,
00262                                 const char *filename, GPContext *context);
00263 
00264 /* Listings */
00265 typedef int (*CameraFilesystemListFunc) (CameraFilesystem *fs,
00266                                          const char *folder, CameraList *list,
00267                                          void *data, GPContext *context);
00268 int gp_filesystem_list_files     (CameraFilesystem *fs, const char *folder,
00269                                   CameraList *list, GPContext *context);
00270 int gp_filesystem_list_folders   (CameraFilesystem *fs, const char *folder,
00271                                   CameraList *list, GPContext *context);
00272 
00273 /* File information */
00274 typedef int (*CameraFilesystemSetInfoFunc) (CameraFilesystem *fs,
00275                                             const char *folder,
00276                                             const char *filename,
00277                                             CameraFileInfo info, void *data,
00278                                             GPContext *context);
00279 typedef int (*CameraFilesystemGetInfoFunc) (CameraFilesystem *fs,
00280                                             const char *folder,
00281                                             const char *filename,
00282                                             CameraFileInfo *info, void *data,
00283                                             GPContext *context);
00284 int gp_filesystem_get_info       (CameraFilesystem *fs, const char *folder,
00285                                   const char *filename, CameraFileInfo *info,
00286                                   GPContext *context);
00287 int gp_filesystem_set_info       (CameraFilesystem *fs, const char *folder,
00288                                   const char *filename, CameraFileInfo info,
00289                                   GPContext *context);
00290 
00291 /* Files */
00292 typedef int (*CameraFilesystemGetFileFunc)    (CameraFilesystem *fs,
00293                                                const char *folder,
00294                                                const char *filename,
00295                                                CameraFileType type,
00296                                                CameraFile *file, void *data,
00297                                                GPContext *context);
00298 typedef int (*CameraFilesystemReadFileFunc)    (CameraFilesystem *fs,
00299                                                const char *folder,
00300                                                const char *filename,
00301                                                CameraFileType type,
00302                                                uint64_t offset,
00303                                                char *buf,
00304                                                uint64_t *size,
00305                                                void *data,
00306                                                GPContext *context);
00307 typedef int (*CameraFilesystemDeleteFileFunc) (CameraFilesystem *fs,
00308                                                const char *folder,
00309                                                const char *filename,
00310                                                void *data, GPContext *context);
00311 int gp_filesystem_get_file       (CameraFilesystem *fs, const char *folder,
00312                                   const char *filename, CameraFileType type,
00313                                   CameraFile *file, GPContext *context);
00314 int gp_filesystem_read_file     (CameraFilesystem *fs, const char *folder,
00315                                  const char *filename, CameraFileType type,
00316                                  uint64_t offset, char *buf, uint64_t *size,
00317                                  GPContext *context);
00318 int gp_filesystem_delete_file    (CameraFilesystem *fs, const char *folder,
00319                                   const char *filename, GPContext *context);
00320 
00321 /* Folders */
00322 typedef int (*CameraFilesystemPutFileFunc)   (CameraFilesystem *fs,
00323                                               const char *folder,
00324                                               const char *filename,
00325                                               CameraFileType type,
00326                                               CameraFile *file,
00327                                               void *data,
00328                                               GPContext *context);
00329 typedef int (*CameraFilesystemDeleteAllFunc) (CameraFilesystem *fs,
00330                                               const char *folder, void *data,
00331                                               GPContext *context);
00332 typedef int (*CameraFilesystemDirFunc)       (CameraFilesystem *fs,
00333                                               const char *folder,
00334                                               const char *name, void *data,
00335                                               GPContext *context);
00336 
00337 typedef int (*CameraFilesystemStorageInfoFunc) (CameraFilesystem *fs,
00338                                               CameraStorageInformation **,
00339                                               int *nrofstorageinformations,
00340                                               void *data, GPContext *context);
00341 
00342 int gp_filesystem_get_storageinfo (CameraFilesystem *fs,
00343                                    CameraStorageInformation **,
00344                                    int *nrofstorageinformations,
00345                                    GPContext *context);
00346 
00347 typedef struct _CameraFilesystemFuncs CameraFilesystemFuncs;
00348 struct _CameraFilesystemFuncs {
00349         CameraFilesystemListFunc        file_list_func;
00350         CameraFilesystemListFunc        folder_list_func;
00351         CameraFilesystemPutFileFunc     put_file_func;
00352         CameraFilesystemDeleteAllFunc   delete_all_func;
00353         CameraFilesystemGetInfoFunc     get_info_func;
00354         CameraFilesystemSetInfoFunc     set_info_func;
00355         CameraFilesystemDirFunc         make_dir_func;
00356         CameraFilesystemDirFunc         remove_dir_func;
00357         CameraFilesystemGetFileFunc     get_file_func;
00358         CameraFilesystemReadFileFunc    read_file_func;
00359         CameraFilesystemDeleteFileFunc  del_file_func;
00360         CameraFilesystemStorageInfoFunc storage_info_func;
00361 
00362         /* for later use. Remove one if you add a new function */
00363         void                            *unused[31];
00364 };
00365 int gp_filesystem_set_funcs     (CameraFilesystem *fs,
00366                                  CameraFilesystemFuncs *funcs,
00367                                  void *data);
00368 int gp_filesystem_put_file   (CameraFilesystem *fs, const char *folder, const char *filename,
00369                               CameraFileType type, CameraFile *file, GPContext *context);
00370 int gp_filesystem_delete_all (CameraFilesystem *fs, const char *folder,
00371                               GPContext *context);
00372 int gp_filesystem_make_dir   (CameraFilesystem *fs, const char *folder,
00373                               const char *name, GPContext *context);
00374 int gp_filesystem_remove_dir (CameraFilesystem *fs, const char *folder,
00375                               const char *name, GPContext *context);
00376 
00377 /* For debugging */
00378 int gp_filesystem_dump         (CameraFilesystem *fs);
00379 
00380 #ifdef __cplusplus
00381 }
00382 #endif /* __cplusplus */
00383 
00384 #endif /* __GPHOTO2_FILESYS_H__ */