CameraFilesystem

Name

CameraFilesystem -- 

Synopsis



            CameraFilesystem;
enum        CameraFilePermissions;
enum        CameraFileStatus;
enum        CameraFileInfoFields;
            CameraFileInfoAudio;
            CameraFileInfoPreview;
            CameraFileInfoFile;
            CameraFileInfo;
int         gp_filesystem_new               (CameraFilesystem **fs);
int         gp_filesystem_free              (CameraFilesystem *fs);
int         (*CameraFilesystemGetFileFunc)  (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileType type,
                                             CameraFile *file,
                                             void *data,
                                             GPContext *context);
int         (*CameraFilesystemDeleteFileFunc)
                                            (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             void *data,
                                             GPContext *context);
int         gp_filesystem_set_file_funcs    (CameraFilesystem *fs,
                                             CameraFilesystemGetFileFunc get_file_func,
                                             CameraFilesystemDeleteFileFunc del_file_func,
                                             void *data);
int         (*CameraFilesystemGetInfoFunc)  (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileInfo *info,
                                             void *data,
                                             GPContext *context);
int         (*CameraFilesystemSetInfoFunc)  (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileInfo info,
                                             void *data,
                                             GPContext *context);
int         gp_filesystem_set_info_funcs    (CameraFilesystem *fs,
                                             CameraFilesystemGetInfoFunc get_info_func,
                                             CameraFilesystemSetInfoFunc set_info_func,
                                             void *data);
int         (*CameraFilesystemPutFileFunc)  (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraFile *file,
                                             void *data,
                                             GPContext *context);
int         (*CameraFilesystemDeleteAllFunc)
                                            (CameraFilesystem *fs,
                                             const char *folder,
                                             void *data,
                                             GPContext *context);
int         (*CameraFilesystemDirFunc)      (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *name,
                                             void *data,
                                             GPContext *context);
int         gp_filesystem_set_folder_funcs  (CameraFilesystem *fs,
                                             CameraFilesystemPutFileFunc put_file_func,
                                             CameraFilesystemDeleteAllFunc delete_all_func,
                                             CameraFilesystemDirFunc make_dir_func,
                                             CameraFilesystemDirFunc remove_dir_func,
                                             void *data);
int         (*CameraFilesystemListFunc)     (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraList *list,
                                             void *data,
                                             GPContext *context);
int         gp_filesystem_set_list_funcs    (CameraFilesystem *fs,
                                             CameraFilesystemListFunc file_list_func,
                                             CameraFilesystemListFunc folder_list_func,
                                             void *data);
int         gp_filesystem_list_files        (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraList *list,
                                             GPContext *context);
int         gp_filesystem_list_folders      (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraList *list,
                                             GPContext *context);
int         gp_filesystem_get_file          (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileType type,
                                             CameraFile *file,
                                             GPContext *context);
int         gp_filesystem_put_file          (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraFile *file,
                                             GPContext *context);
int         gp_filesystem_delete_file       (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             GPContext *context);
int         gp_filesystem_delete_all        (CameraFilesystem *fs,
                                             const char *folder,
                                             GPContext *context);
int         gp_filesystem_make_dir          (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *name,
                                             GPContext *context);
int         gp_filesystem_remove_dir        (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *name,
                                             GPContext *context);
int         gp_filesystem_get_info          (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileInfo *info,
                                             GPContext *context);
int         gp_filesystem_set_info          (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileInfo info,
                                             GPContext *context);
int         gp_filesystem_set_info_noop     (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraFileInfo info,
                                             GPContext *context);
int         gp_filesystem_number            (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             GPContext *context);
int         gp_filesystem_name              (CameraFilesystem *fs,
                                             const char *folder,
                                             int filenumber,
                                             const char **filename,
                                             GPContext *context);
int         gp_filesystem_get_folder        (CameraFilesystem *fs,
                                             const char *filename,
                                             const char **folder,
                                             GPContext *context);
int         gp_filesystem_count             (CameraFilesystem *fs,
                                             const char *folder,
                                             GPContext *context);
int         gp_filesystem_reset             (CameraFilesystem *fs);
int         gp_filesystem_append            (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             GPContext *context);
int         gp_filesystem_set_file_noop     (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraFile *file,
                                             GPContext *context);
int         gp_filesystem_dump              (CameraFilesystem *fs);

Description

Details

CameraFilesystem

typedef struct _CameraFilesystem CameraFilesystem;

The internals of the CameraFilesystem are only visible to gphoto2. You can only access them using the functions provided by gphoto2.


enum CameraFilePermissions

typedef enum {
	GP_FILE_PERM_NONE       = 0,
	GP_FILE_PERM_READ       = 1 << 0,
	GP_FILE_PERM_DELETE     = 1 << 1,
	GP_FILE_PERM_ALL        = 0xFF
} CameraFilePermissions;


enum CameraFileStatus

typedef enum {
	GP_FILE_STATUS_NOT_DOWNLOADED,
	GP_FILE_STATUS_DOWNLOADED
} CameraFileStatus;


enum CameraFileInfoFields

typedef enum {
	GP_FILE_INFO_NONE            = 0,
	GP_FILE_INFO_TYPE            = 1 << 0,
	GP_FILE_INFO_NAME            = 1 << 1,
	GP_FILE_INFO_SIZE            = 1 << 2,
	GP_FILE_INFO_WIDTH           = 1 << 3,
	GP_FILE_INFO_HEIGHT          = 1 << 4,
	GP_FILE_INFO_PERMISSIONS     = 1 << 5,
	GP_FILE_INFO_STATUS	     = 1 << 6,
	GP_FILE_INFO_MTIME	     = 1 << 7,
	GP_FILE_INFO_ALL             = 0xFF
} CameraFileInfoFields;


CameraFileInfoAudio

typedef struct {
	CameraFileInfoFields fields;
	CameraFileStatus status;
	unsigned long size;
	char type[64];
} CameraFileInfoAudio;


CameraFileInfoPreview

typedef struct {
	CameraFileInfoFields fields;
	CameraFileStatus status;
	unsigned long size;
	char type[64];

	unsigned int width, height;
} CameraFileInfoPreview;


CameraFileInfoFile

typedef struct {
	CameraFileInfoFields fields;
	CameraFileStatus status;
	unsigned long size;
	char type[64];

	unsigned int width, height;
	char name[64];
	CameraFilePermissions permissions;
	time_t mtime;
} CameraFileInfoFile;


CameraFileInfo

typedef struct {
	CameraFileInfoPreview preview;
	CameraFileInfoFile    file;
	CameraFileInfoAudio   audio;
} CameraFileInfo;


gp_filesystem_new ()

int         gp_filesystem_new               (CameraFilesystem **fs);

Creates a new empty CameraFilesystem

fs :

a pointer to a CameraFilesystem

Returns :

a gphoto2 error code.


gp_filesystem_free ()

int         gp_filesystem_free              (CameraFilesystem *fs);

Frees the CameraFilesystem

fs :

a CameraFilesystem

Returns :

a gphoto2 error code.


CameraFilesystemGetFileFunc ()

int         (*CameraFilesystemGetFileFunc)  (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileType type,
                                             CameraFile *file,
                                             void *data,
                                             GPContext *context);

fs :

folder :

filename :

type :

file :

data :

context :

Returns :


CameraFilesystemDeleteFileFunc ()

int         (*CameraFilesystemDeleteFileFunc)
                                            (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             void *data,
                                             GPContext *context);

fs :

folder :

filename :

data :

context :

Returns :


gp_filesystem_set_file_funcs ()

int         gp_filesystem_set_file_funcs    (CameraFilesystem *fs,
                                             CameraFilesystemGetFileFunc get_file_func,
                                             CameraFilesystemDeleteFileFunc del_file_func,
                                             void *data);

Tells the fs which functions to use for file download or file deletion. Typically, a camera driver would call this function on initialization. A function can be NULL indicating that this functionality is not supported. For example, if a camera does not support file deletion, you would supply NULL for del_file_func.

fs :

a CameraFilesystem

get_file_func :

the function downloading files

del_file_func :

the function deleting files

data :

Returns :

a gphoto2 error code.


CameraFilesystemGetInfoFunc ()

int         (*CameraFilesystemGetInfoFunc)  (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileInfo *info,
                                             void *data,
                                             GPContext *context);

fs :

folder :

filename :

info :

data :

context :

Returns :


CameraFilesystemSetInfoFunc ()

int         (*CameraFilesystemSetInfoFunc)  (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileInfo info,
                                             void *data,
                                             GPContext *context);

fs :

folder :

filename :

info :

data :

context :

Returns :


gp_filesystem_set_info_funcs ()

int         gp_filesystem_set_info_funcs    (CameraFilesystem *fs,
                                             CameraFilesystemGetInfoFunc get_info_func,
                                             CameraFilesystemSetInfoFunc set_info_func,
                                             void *data);

Tells the filesystem which functions to call when file information about a file should be retrieved or set. Typically, this function will get called by the camera driver on initialization.

fs :

a CameraFilesystem

get_info_func :

the function to retrieve file information

set_info_func :

the function to set file information

data :

Returns :

a gphoto2 error code.


CameraFilesystemPutFileFunc ()

int         (*CameraFilesystemPutFileFunc)  (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraFile *file,
                                             void *data,
                                             GPContext *context);

fs :

folder :

file :

data :

context :

Returns :


CameraFilesystemDeleteAllFunc ()

int         (*CameraFilesystemDeleteAllFunc)
                                            (CameraFilesystem *fs,
                                             const char *folder,
                                             void *data,
                                             GPContext *context);

fs :

folder :

data :

context :

Returns :


CameraFilesystemDirFunc ()

int         (*CameraFilesystemDirFunc)      (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *name,
                                             void *data,
                                             GPContext *context);

fs :

folder :

name :

data :

context :

Returns :


gp_filesystem_set_folder_funcs ()

int         gp_filesystem_set_folder_funcs  (CameraFilesystem *fs,
                                             CameraFilesystemPutFileFunc put_file_func,
                                             CameraFilesystemDeleteAllFunc delete_all_func,
                                             CameraFilesystemDirFunc make_dir_func,
                                             CameraFilesystemDirFunc remove_dir_func,
                                             void *data);

Tells the filesystem which functions to call for file upload, deletion of all files in a given folder, creation or removal of a folder. Typically, a camera driver would call this function on initialization. If one functionality is not supported, NULL can be supplied. If you don't call this function, the fs will assume that neither of these features is supported.

The fs will try to compensate missing delete_all_func functionality with the delete_file_func if such a function has been supplied.

fs :

a CameraFilesystem

put_file_func :

function used to upload files

delete_all_func :

function used to delete all files in a folder

make_dir_func :

function used to create a new directory

remove_dir_func :

function used to remove an existing directory

data :

a data object that will passed to all called functions

Returns :

a gphoto2 error code.


CameraFilesystemListFunc ()

int         (*CameraFilesystemListFunc)     (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraList *list,
                                             void *data,
                                             GPContext *context);

fs :

folder :

list :

data :

context :

Returns :


gp_filesystem_set_list_funcs ()

int         gp_filesystem_set_list_funcs    (CameraFilesystem *fs,
                                             CameraFilesystemListFunc file_list_func,
                                             CameraFilesystemListFunc folder_list_func,
                                             void *data);

Tells the fs which functions to use to retrieve listings of folders and/or files. Typically, a camera driver would call this function on initialization. Each function can be NULL indicating that this functionality is not supported. For example, many cameras don't support folders. In this case, you would supply NULL for folder_list_func. Then, the fs assumes that there is only a root folder.

fs :

a CameraFilesystem

file_list_func :

the function that will return listings of files

folder_list_func :

the function that will return listings of folders

data :

Returns :

a gphoto2 error code.


gp_filesystem_list_files ()

int         gp_filesystem_list_files        (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraList *list,
                                             GPContext *context);

Lists the files in folder using either cached values or (if there aren't any) the file_list_func which (hopefully) has been previously supplied.

fs :

a CameraFilesystem

folder :

a folder of which a file list should be generated

list :

a CameraList where to put the list of files into

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_list_folders ()

int         gp_filesystem_list_folders      (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraList *list,
                                             GPContext *context);

Generates a list of subfolders of the supplied folder either using cached values (if there are any) or the folder_list_func if it has been supplied previously. If not, it is assumed that only a root folder exists (which is the case for many cameras).

fs :

a CameraFilesystem

folder :

a folder

list :

a CameraList where subfolders should be listed

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_get_file ()

int         gp_filesystem_get_file          (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileType type,
                                             CameraFile *file,
                                             GPContext *context);

Downloads the file called filename from the folder using the get_file_func if such a function has been previously supplied. If the file has been previously downloaded, the file is retrieved from cache.

fs :

a CameraFilesystem

folder :

the folder in which the file can be found

filename :

the name of the file to download

type :

the type of the file

file :

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_put_file ()

int         gp_filesystem_put_file          (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraFile *file,
                                             GPContext *context);

Uploads a file to the camera if a put_file_func has been previously supplied to the fs. If the upload is successful, the file will get cached in the fs.

fs :

a CameraFilesystem

folder :

the folder where to put the file into

file :

the file

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_delete_file ()

int         gp_filesystem_delete_file       (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             GPContext *context);

If a delete_file_func has been supplied to the fs, this function will be called and, if this function returns without error, the file will be removed from the fs.

fs :

a CameraFilesystem

folder :

a folder in which to delete the file

filename :

the name of the file to delete

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_delete_all ()

int         gp_filesystem_delete_all        (CameraFilesystem *fs,
                                             const char *folder,
                                             GPContext *context);

Deletes all files in the given folder from the fs. If the fs has not been supplied with a delete_all_func, it tries to delete the files one by one using the delete_file_func. If that function has not been supplied neither, an error is returned.

fs :

a CameraFilesystem

folder :

the folder in which to delete all files

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_make_dir ()

int         gp_filesystem_make_dir          (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *name,
                                             GPContext *context);

Creates a new directory called name in given folder.

fs :

a CameraFilesystem

folder :

the folder in which the directory should be created

name :

the name of the directory to be created

context :

a GPContext

Returns :

a gphoto2 error code


gp_filesystem_remove_dir ()

int         gp_filesystem_remove_dir        (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *name,
                                             GPContext *context);

fs :

folder :

name :

context :

Returns :


gp_filesystem_get_info ()

int         gp_filesystem_get_info          (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileInfo *info,
                                             GPContext *context);

fs :

a CameraFilesystem

folder :

filename :

info :

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_set_info ()

int         gp_filesystem_set_info          (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             CameraFileInfo info,
                                             GPContext *context);

fs :

a CameraFilesystem

folder :

filename :

info :

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_set_info_noop ()

int         gp_filesystem_set_info_noop     (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraFileInfo info,
                                             GPContext *context);

In contrast to gp_filesystem_set_info, gp_filesystem_set_info_noop will only change the file information in the fs. Typically, camera drivers will use this function in case they get file information "for free" on gp_camera_capture or gp_camera_folder_list_files.

fs :

a CameraFilesystem

folder :

info :

context :

a GPContext

Returns :

a gphoto2 error code


gp_filesystem_number ()

int         gp_filesystem_number            (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             GPContext *context);

Looks for a file called filename in the given folder. See gp_filesystem_name for exactly the opposite functionality.

fs :

a CameraFilesystem

folder :

the folder where to look for file called filename

filename :

the file to look for

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_name ()

int         gp_filesystem_name              (CameraFilesystem *fs,
                                             const char *folder,
                                             int filenumber,
                                             const char **filename,
                                             GPContext *context);

Looks up the filename of file with given filenumber in given folder. See gp_filesystem_number for exactly the opposite functionality.

fs :

a CameraFilesystem

folder :

the folder where to look up the file with the filenumber

filenumber :

the number of the file

filename :

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_get_folder ()

int         gp_filesystem_get_folder        (CameraFilesystem *fs,
                                             const char *filename,
                                             const char **folder,
                                             GPContext *context);

Searches a file called filename in the fs and returns the first occurrency. This functionality is needed for camera drivers that cannot figure out where a file gets created after capturing an image although the name of the image is known. Usually, those drivers will call gp_filesystem_reset in order to tell the fs that something has changed and then gp_filesystem_get_folder in order to find the file.

fs :

a CameraFilesystem

filename :

the name of the file to search in the fs

folder :

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_count ()

int         gp_filesystem_count             (CameraFilesystem *fs,
                                             const char *folder,
                                             GPContext *context);

Counts the files in the folder.

fs :

a CameraFilesystem

folder :

a folder in which to count the files

context :

a GPContext

Returns :

The number of files in the folder or a gphoto2 error code.


gp_filesystem_reset ()

int         gp_filesystem_reset             (CameraFilesystem *fs);

Resets the filesystem. All cached information including the folder tree will get lost and will be queried again on demand.

fs :

a CameraFilesystem

Returns :

a gphoto2 error code.


gp_filesystem_append ()

int         gp_filesystem_append            (CameraFilesystem *fs,
                                             const char *folder,
                                             const char *filename,
                                             GPContext *context);

Tells the fs that there is a file called filename in folder called folder. Usually, camera drivers will call this function after capturing an image in order to tell the fs about the new file. A front-end should not use this function.

fs :

a CameraFilesystem

folder :

the folder where to put the file in

filename :

filename of the file

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_set_file_noop ()

int         gp_filesystem_set_file_noop     (CameraFilesystem *fs,
                                             const char *folder,
                                             CameraFile *file,
                                             GPContext *context);

Tells the fs about a file. Typically, camera drivers will call this function in case they get information about a file (i.e. preview) "for free" on gp_camera_capture or gp_camera_folder_list_files.

fs :

a CameraFilesystem

folder :

file :

a CameraFile

context :

a GPContext

Returns :

a gphoto2 error code.


gp_filesystem_dump ()

int         gp_filesystem_dump              (CameraFilesystem *fs);

fs :

Returns :