gphoto2-filesys.c File Reference
`#include "config.h"`
`#include <gphoto2/gphoto2-filesys.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <stdio.h>`
`#include <unistd.h>`
`#include <gphoto2/gphoto2-result.h>`
`#include <gphoto2/gphoto2-port-log.h>`
`#include <gphoto2/gphoto2-setting.h>`
`#include <limits.h>`

## Data Structures

struct | _CameraFilesystemFile
struct | _CameraFilesystemFolder
struct | _CameraFilesystem
| The internal camera filesystem structure. More...

## Macros

#define | _BSD_SOURCE
#define | textdomain(String) (String)
#define | gettext(String) (String)
#define | dgettext(Domain, Message) (Message)
#define | dcgettext(Domain, Message, Type) (Message)
#define | bindtextdomain(Domain, Directory) (Domain)
#define | _(String) (String)
#define | N_(String) (String)
#define | GP_MODULE "libgphoto2"
#define | PATH_MAX 4096
#define | PICTURES_TO_KEEP 2
#define | MIN(a, b) (((a) < (b)) ? (a) : (b))
#define | CHECK_NULL(r) {if (!(r)) return (GP_ERROR_BAD_PARAMETERS);}
#define | CR(result) {int r = (result); if (r < 0) return (r);}
#define | CHECK_MEM(m) {if (!(m)) return (GP_ERROR_NO_MEMORY);}
#define | CL(result, list)
#define | CU(result, file)
#define | CC(context)
#define | CA(f, c)

## Typedefs

typedef struct _CameraFilesystemFile | CameraFilesystemFile
typedef struct _CameraFilesystemFolder | CameraFilesystemFolder

## Functions

int | gp_filesystem_reset (CameraFilesystem *fs)
| Clear the filesystem. More...
int | gp_filesystem_new (CameraFilesystem **fs)
| Create a new filesystem struct. More...
int | gp_filesystem_free (CameraFilesystem *fs)
| Free filesystem struct. More...
int | gp_filesystem_append (CameraFilesystem *fs, const char *folder, const char *filename, GPContext *context)
| Append a file to a folder in a filesystem. More...
int | gp_filesystem_dump (CameraFilesystem *fs)
| Dump the current filesystem. More...
int | gp_filesystem_delete_all (CameraFilesystem *fs, const char *folder, GPContext *context)
| Delete all files in specified folder. More...
int | gp_filesystem_list_files (CameraFilesystem *fs, const char *folder, CameraList *list, GPContext *context)
| Get the list of files in a folder. More...
int | gp_filesystem_list_folders (CameraFilesystem *fs, const char *folder, CameraList *list, GPContext *context)
| List all subfolders within a filesystem folder. More...
int | gp_filesystem_count (CameraFilesystem *fs, const char *folder, GPContext *context)
| Count files a folder of a filesystem. More...
int | gp_filesystem_delete_file (CameraFilesystem *fs, const char *folder, const char *filename, GPContext *context)
| Delete a file from a folder. More...
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. More...
int | gp_filesystem_make_dir (CameraFilesystem *fs, const char *folder, const char *name, GPContext *context)
| Create a subfolder within a folder. More...
int | gp_filesystem_remove_dir (CameraFilesystem *fs, const char *folder, const char *name, GPContext *context)
| Remove a subfolder from within a folder. More...
int | gp_filesystem_put_file (CameraFilesystem *fs, const char *folder, CameraFile *file, GPContext *context)
| Upload a file to a folder on the device filesystem. More...
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. More...
int | gp_filesystem_number (CameraFilesystem *fs, const char *folder, const char *filename, GPContext *context)
| Get the index of a file in specified folder. More...
int | gp_filesystem_get_folder (CameraFilesystem *fs, const char *filename, const char **folder, GPContext *context)
| Search a folder that contains a given filename. More...
int | gp_filesystem_set_list_funcs (CameraFilesystem *fs, CameraFilesystemListFunc file_list_func, CameraFilesystemListFunc folder_list_func, void *data)
| Set the functions to list folders and files. More...
int | gp_filesystem_set_file_funcs (CameraFilesystem *fs, CameraFilesystemGetFileFunc get_file_func, CameraFilesystemDeleteFileFunc del_file_func, void *data)
| Set camera filesystem file related functions. More...
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)
| Set folder related functions of the filesystem. More...
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. More...
int | gp_filesystem_set_info_funcs (CameraFilesystem *fs, CameraFilesystemGetInfoFunc get_info_func, CameraFilesystemSetInfoFunc set_info_func, void *data)
| Set file information functions. More...
int | gp_filesystem_set_funcs (CameraFilesystem *fs, CameraFilesystemFuncs *funcs, void *data)
| Set all filesystem related function pointers. More...
int | gp_filesystem_get_info (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo *info, GPContext *context)
| Get information about the specified file. More...
int | gp_filesystem_set_file_noop (CameraFilesystem *fs, const char *folder, CameraFile *file, GPContext *context)
| Attach file content to a specified file. More...
int | gp_filesystem_set_info_noop (CameraFilesystem *fs, const char *folder, CameraFileInfo info, GPContext *context)
| Store the file information in the virtual fs. More...
int | gp_filesystem_set_info (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo info, GPContext *context)
| Set information about a file. More...
int | gp_filesystem_get_storageinfo (CameraFilesystem *fs, CameraStorageInformation **storageinfo, int *nrofstorageinfos, GPContext *context)
| Get the storage information about this filesystem. More...

## Detailed Description

Author
  Copyright 2000 Scott Fritzinger
  Contributions Lutz Müller lutz@.nosp@m.user.nosp@m.s.sf..nosp@m.net (2001)
  Copyright 2009 Marcus Meissner

License
  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

## Macro Definition Documentation

#define CA | ( |  | f,
|  |  | c
| ) |  |

Value:
{ \
if ((f)[0] != '/') { \
gp_context_error ((c), \
_("The path '%s' is not absolute."), (f)); \
return (GP_ERROR_PATH_NOT_ABSOLUTE); \
} \
}
GP_ERROR_PATH_NOT_ABSOLUTE
#define GP_ERROR_PATH_NOT_ABSOLUTE
Path is not absolute.
Definition: gphoto2-result.h:99

#define CC | ( |  | context | ) |

Value:
{ \
if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) \
return GP_ERROR_CANCEL; \
}
gp_context_cancel
GPContextFeedback gp_context_cancel(GPContext *context)
Definition: gphoto2-context.c:315
GP_CONTEXT_FEEDBACK_CANCEL
Definition: gphoto2-context.h:57
GP_ERROR_CANCEL
#define GP_ERROR_CANCEL
Cancellation successful.
Definition: gphoto2-result.h:107

#define CL | ( |  | result,
|  |  | list
| ) |  |

Value:
{ \
int r = (result); \
\
if (r < 0) { \
gp_list_free (list); \
return (r); \
} \
}
gp_list_free
int gp_list_free(CameraList *list)
Definition: gphoto2-list.c:178

#define CU | ( |  | result,
|  |  | file
| ) |  |

Value:
{ \
int r = (result); \
\
if (r < 0) { \
gp_file_unref (file); \
return (r); \
} \
}
gp_file_unref
int gp_file_unref(CameraFile *file)
Decrease reference counter for CameraFile object.
Definition: gphoto2-file.c:167

#define PICTURES_TO_KEEP 2

The default number of pictures to keep in the internal cache, can be overriden by settings.

## Function Documentation

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

Append a file to a folder in a filesystem.

Parameters

  fs | a CameraFilesystem
  folder | the folder where to put the file in
  filename | filename of the file
  context | a GPContext

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.

Returns
  a gphoto2 error code.

References GP_ERROR_FILE_EXISTS, GP_ERROR_NO_MEMORY, gp_log(), GP_LOG_DEBUG, and GP_OK.

Referenced by gp_filesystem_list_files().

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

Count files a folder of a filesystem.

Parameters

  fs | a CameraFilesystem
  folder | a folder in which to count the files
  context | a GPContext

Counts the files in the folder.

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

References GP_ERROR_DIRECTORY_NOT_FOUND.

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

Delete all files in specified folder.

Parameters

  fs | a CameraFilesystem
  folder | the folder in which to delete all files
  context | a GPContext

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.

Returns
  a gphoto2 error code.

References GP_ERROR_DIRECTORY_NOT_FOUND, gp_log(), GP_LOG_DEBUG, GP_OK, and gp_result_as_string().

Referenced by gp_camera_folder_delete_all().

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

Delete a file from a folder.

Parameters

  fs | a CameraFilesystem
  folder | a folder in which to delete the file
  filename | the name of the file to delete
  context | a GPContext

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.

Returns
  a gphoto2 error code.

References GP_ERROR_NOT_SUPPORTED, and GP_OK.

Referenced by gp_camera_file_delete().

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.

Parameters

  fs | a CameraFilesystem
  folder | a folder in which to delete the file
  filename | the name of the file to delete
  context | a GPContext

Remove a file from the filesystem. Compared to gp_filesystem_delete_file() this just removes the file from the libgphoto2 view of the filesystem, but does not call the camera driver to delete it from the physical device.

Returns
  a gphoto2 error code.

int gp_filesystem_dump | ( | CameraFilesystem * | fs | ) |

Dump the current filesystem.

Parameters

  fs | the CameraFilesystem

Returns
  a gphoto error code

Internal function to dump the current filesystem.

References GP_OK.

int gp_filesystem_free | ( | CameraFilesystem * | fs | ) |

Free filesystem struct.

Parameters

  fs | a CameraFilesystem

Frees the CameraFilesystem

Returns
  a gphoto2 error code.

References gp_filesystem_reset(), and GP_OK.

Referenced by gp_camera_free().

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.

Parameters

  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 | the file that receives the data
  context | a GPContext

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. The result is stored in the passed file structure.

Returns
  a gphoto2 error code.

References GP_ERROR_CORRUPTED_DATA, GP_ERROR_NOT_SUPPORTED, gp_file_adjust_name_for_mime_type(), gp_file_get_data_and_size(), gp_file_new(), gp_file_set_data_and_size(), gp_file_set_mime_type(), gp_file_set_name(), gp_file_set_type(), GP_FILE_TYPE_EXIF, GP_FILE_TYPE_PREVIEW, gp_file_unref(), gp_filesystem_set_file_noop(), GP_OK, and gp_result_as_string().

Referenced by gp_camera_file_get().

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

Search a folder that contains a given filename.

Parameters

  fs | a CameraFilesystem
  filename | the name of the file to search in the fs
  folder | pointer to value where the string is stored in
  context | a GPContext

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.

Note that you get a reference to the string stored in the filesystem structure, so do not free it yourself.

Returns
  a gphoto2 error code.

References GP_ERROR_FILE_NOT_FOUND, and GP_OK.

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

Get information about the specified file.

Parameters

  fs | a CameraFilesystem
  folder | the folder that contains the file
  filename | the filename
  info | pointer to CameraFileInfo that receives the information
  context | a GPContext

Returns
  a gphoto2 error code.

References _CameraFileInfoFile::fields, GP_ERROR_NOT_SUPPORTED, GP_FILE_INFO_MTIME, GP_OK, and _CameraFileInfoFile::mtime.

Referenced by gp_camera_file_get_info(), and gp_filesystem_set_file_noop().

int gp_filesystem_get_storageinfo | ( | CameraFilesystem * | fs,
|  | CameraStorageInformation ** | storageinfo,
|  | int * | nrofstorageinfos,
|  | GPContext * | context
| ) |  |

Get the storage information about this filesystem.

Parameters

  fs | the filesystem
  storageinfo | Pointer to receive a pointer to/array of storage info items
  nrofstorageinfos | Pointer to receive number of array entries
  context | a GPContext

This function is only called from gp_camera_get_storageinfo(). You may want to make sure this information is consistent with the information on gp_camera_get_storageinfo().

Retrieves the storage information, like maximum and free space, for the specified filesystem, if supported by the device. The storage information is returned in an newly allocated array of CameraStorageInformation objects, to which the pointer pointed to by #storageinfo will be set.

The variable pointed to by #nrofstorageinfos will be set to the number of elements in that array.

It is the caller's responsibility to free the memory of the array.

Returns
  a gphoto error code

References GP_ERROR_NOT_SUPPORTED.

Referenced by gp_camera_get_storageinfo().

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

Get the list of files in a folder.

Parameters

  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

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.

Returns
  a gphoto2 error code.

References GP_ERROR_DIRECTORY_NOT_FOUND, gp_filesystem_append(), gp_list_append(), gp_list_count(), gp_list_get_name(), gp_list_reset(), gp_log(), GP_LOG_DEBUG, and GP_OK.

Referenced by gp_camera_folder_list_files(), and gp_filesystem_number().

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

List all subfolders within a filesystem folder.

Parameters

  fs | a CameraFilesystem
  folder | a folder
  list | a CameraList where subfolders should be listed
  context | a GPContext

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).

Returns
  a gphoto2 error code.

References GP_ERROR_DIRECTORY_NOT_FOUND, gp_list_append(), gp_list_count(), gp_list_get_name(), gp_list_reset(), gp_log(), GP_LOG_DEBUG, and GP_OK.

Referenced by gp_camera_folder_list_folders(), and gp_filesystem_remove_dir().

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

Create a subfolder within a folder.

Parameters

  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

Creates a new directory called name in given folder.

Returns
  a gphoto2 error code

References GP_ERROR_DIRECTORY_NOT_FOUND, and GP_ERROR_NOT_SUPPORTED.

Referenced by gp_camera_folder_make_dir().

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.

Parameters

  fs | a CameraFilesystem
  folder | the folder where to look up the file with the filenumber
  filenumber | the number of the file
  filename | pointer to a filename where the result is stored
  context | a GPContext

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

Returns
  a gphoto2 error code.

References GP_ERROR_DIRECTORY_NOT_FOUND, GP_ERROR_FILE_NOT_FOUND, and GP_OK.

int gp_filesystem_new | ( | CameraFilesystem ** | fs | ) |

Create a new filesystem struct.

Parameters

  fs | a pointer to a CameraFilesystem

Creates a new empty CameraFilesystem

Returns
  a gphoto2 error code.

References GP_ERROR_NO_MEMORY, and GP_OK.

Referenced by gp_camera_new().

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

Get the index of a file in specified folder.

Parameters

  fs | a CameraFilesystem
  folder | the folder where to look for file called filename
  filename | the file to look for
  context | a GPContext

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

Returns
  a gphoto2 error code.

References GP_ERROR_DIRECTORY_NOT_FOUND, GP_ERROR_FILE_NOT_FOUND, gp_filesystem_list_files(), gp_filesystem_number(), gp_list_free(), and gp_list_new().

Referenced by gp_filesystem_number(), and gp_filesystem_set_info().

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

Upload a file to a folder on the device filesystem.

Parameters

  fs | a CameraFilesystem
  folder | the folder where to put the file into
  file | the file
  context | a GPContext

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.

Returns
  a gphoto2 error code.

References GP_ERROR_DIRECTORY_NOT_FOUND, and GP_ERROR_NOT_SUPPORTED.

Referenced by gp_camera_folder_put_file().

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

Remove a subfolder from within a folder.

Parameters

  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

Removes a directory called name from the given folder.

Returns
  a gphoto2 error code

References GP_ERROR_DIRECTORY_EXISTS, GP_ERROR_DIRECTORY_NOT_FOUND, GP_ERROR_FILE_EXISTS, GP_ERROR_NOT_SUPPORTED, gp_filesystem_list_folders(), gp_list_free(), gp_list_new(), gp_log(), GP_LOG_DEBUG, and GP_OK.

Referenced by gp_camera_folder_remove_dir().

int gp_filesystem_reset | ( | CameraFilesystem * | fs | ) |

Clear the filesystem.

Parameters

  fs | the filesystem to be cleared

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

Returns
  a gphoto2 error code.

References gp_log(), GP_LOG_DEBUG, GP_LOG_ERROR, and GP_OK.

Referenced by gp_camera_exit(), and gp_filesystem_free().

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

Set camera filesystem file related functions.

Parameters

  fs | a CameraFilesystem
  get_file_func | the function downloading files
  del_file_func | the function deleting files
  data | private data structure

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.

Returns
  a gphoto2 error code.

References get_file_func(), and GP_OK.

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

Attach file content to a specified file.

Parameters

  fs | a CameraFilesystem
  folder | a folder in the filesystem
  file | a CameraFile
  context | a GPContext

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().

Returns
  a gphoto2 error code.

References _CameraFileInfoFile::fields, GP_ERROR, gp_file_get_data_and_size(), gp_file_get_mtime(), gp_file_get_name(), gp_file_get_type(), GP_FILE_INFO_MTIME, gp_file_ref(), gp_file_set_mtime(), GP_FILE_TYPE_AUDIO, GP_FILE_TYPE_EXIF, GP_FILE_TYPE_METADATA, GP_FILE_TYPE_NORMAL, GP_FILE_TYPE_PREVIEW, GP_FILE_TYPE_RAW, gp_file_unref(), gp_filesystem_get_info(), GP_OK, and _CameraFileInfoFile::mtime.

Referenced by gp_filesystem_get_file().

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
| ) |  |

Set folder related functions of the filesystem.

Parameters

  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

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.

Returns
  a gphoto2 error code.

References delete_all_func(), GP_OK, and put_file_func().

int gp_filesystem_set_funcs | ( | CameraFilesystem * | fs,
|  | CameraFilesystemFuncs * | funcs,
|  | void * | data
| ) |  |

Set all filesystem related function pointers.

Parameters

  fs | a CameraFilesystem
  funcs | pointer to a struct of filesystem functions
  data | private data

Tells the filesystem which functions to call for camera/filesystem specific functions, like listing, retrieving, uploading files and so on.

Returns
  a gphoto2 error code.

References GP_OK.

Referenced by camera_init().

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

Set information about a file.

Parameters

  fs | a CameraFilesystem
  folder | foldername where the file resides
  filename | the files name
  info | the CameraFileInfo to set
  context | a GPContext

Sets information about a file in the camera.

Returns
  a gphoto2 error code.

References _CameraFileInfoFile::fields, _CameraFileInfoPreview::fields, _CameraFileInfoAudio::fields, GP_ERROR_BAD_PARAMETERS, GP_ERROR_FILE_NOT_FOUND, GP_ERROR_NOT_SUPPORTED, GP_FILE_INFO_HEIGHT, GP_FILE_INFO_NAME, GP_FILE_INFO_NONE, GP_FILE_INFO_PERMISSIONS, GP_FILE_INFO_SIZE, GP_FILE_INFO_STATUS, GP_FILE_INFO_TYPE, GP_FILE_INFO_WIDTH, gp_filesystem_number(), GP_OK, _CameraFileInfoFile::name, and _CameraFileInfoFile::permissions.

Referenced by gp_camera_file_set_info().

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

Set file information functions.

Parameters

  fs | a CameraFilesystem
  get_info_func | the function to retrieve file information
  set_info_func | the function to set file information
  data | private 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.

Returns
  a gphoto2 error code.

References get_info_func(), GP_OK, and set_info_func().

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

Store the file information in the virtual fs.

Parameters

  fs | a CameraFilesystem
  folder | the foldername
  info | the CameraFileInfo to store
  context | a GPContext

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.

Returns
  a gphoto2 error code

References GP_OK, and _CameraFileInfoFile::name.

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

Set the functions to list folders and files.

Parameters

  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 | private data structure

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.

Returns
  a gphoto2 error code.

References file_list_func(), folder_list_func(), and GP_OK.