libgphoto2 photo camera library (libgphoto2) API  2.5.10.1
gphoto2-filesys.h File Reference

Filesystem related operations and declarations. More...

#include <time.h>
#include <stdint.h>
#include <gphoto2/gphoto2-context.h>
#include <gphoto2/gphoto2-list.h>
#include <gphoto2/gphoto2-file.h>
Include dependency graph for gphoto2-filesys.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _CameraFileInfoFile
 File information of a regular file. More...
 
struct  _CameraFileInfoPreview
 File information of a preview file. More...
 
struct  _CameraFileInfoAudio
 File information of an audio file. More...
 
struct  _CameraFileInfo
 File information structure. More...
 
struct  _CameraStorageInformation
 Storage information structue. More...
 
struct  _CameraFilesystemFuncs
 

Typedefs

typedef struct _CameraFileInfoFile CameraFileInfoFile
 File information of a regular file. More...
 
typedef struct _CameraFileInfoPreview CameraFileInfoPreview
 File information of a preview file. More...
 
typedef struct _CameraFileInfoAudio CameraFileInfoAudio
 File information of an audio file. More...
 
typedef struct _CameraFileInfo CameraFileInfo
 File information structure. More...
 
typedef struct _CameraStorageInformation CameraStorageInformation
 Storage information structue. More...
 
typedef struct _CameraFilesystem CameraFilesystem
 Filesystem structure, only exposed to camera drivers. More...
 
typedef int(* CameraFilesystemListFunc) (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context)
 
typedef int(* CameraFilesystemSetInfoFunc) (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo info, void *data, GPContext *context)
 
typedef int(* CameraFilesystemGetInfoFunc) (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo *info, void *data, GPContext *context)
 
typedef int(* CameraFilesystemGetFileFunc) (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *data, GPContext *context)
 
typedef int(* CameraFilesystemReadFileFunc) (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, uint64_t offset, char *buf, uint64_t *size, void *data, GPContext *context)
 
typedef int(* CameraFilesystemDeleteFileFunc) (CameraFilesystem *fs, const char *folder, const char *filename, void *data, GPContext *context)
 
typedef int(* CameraFilesystemPutFileFunc) (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *data, GPContext *context)
 
typedef int(* CameraFilesystemDeleteAllFunc) (CameraFilesystem *fs, const char *folder, void *data, GPContext *context)
 
typedef int(* CameraFilesystemDirFunc) (CameraFilesystem *fs, const char *folder, const char *name, void *data, GPContext *context)
 
typedef int(* CameraFilesystemStorageInfoFunc) (CameraFilesystem *fs, CameraStorageInformation **, int *nrofstorageinformations, void *data, GPContext *context)
 
typedef struct _CameraFilesystemFuncs CameraFilesystemFuncs
 

Enumerations

enum  CameraFileInfoFields {
  GP_FILE_INFO_NONE = 0, GP_FILE_INFO_TYPE = 1 << 0, 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
}
 Bitmask on what fields are set in the CameraFileInfo structure. More...
 
enum  CameraFilePermissions { GP_FILE_PERM_NONE = 0, GP_FILE_PERM_READ = 1 << 0, GP_FILE_PERM_DELETE = 1 << 1, GP_FILE_PERM_ALL = 0xFF }
 Bitmask containing the file permission flags. More...
 
enum  CameraFileStatus { GP_FILE_STATUS_NOT_DOWNLOADED, GP_FILE_STATUS_DOWNLOADED }
 Possible status values. More...
 
enum  CameraStorageInfoFields {
  GP_STORAGEINFO_BASE = (1<<0), GP_STORAGEINFO_LABEL = (1<<1), GP_STORAGEINFO_DESCRIPTION = (1<<2), GP_STORAGEINFO_ACCESS = (1<<3),
  GP_STORAGEINFO_STORAGETYPE = (1<<4), GP_STORAGEINFO_FILESYSTEMTYPE = (1<<5), GP_STORAGEINFO_MAXCAPACITY = (1<<6), GP_STORAGEINFO_FREESPACEKBYTES = (1<<7),
  GP_STORAGEINFO_FREESPACEIMAGES = (1<<8)
}
 Storage information flags. More...
 
enum  CameraStorageType {
  GP_STORAGEINFO_ST_UNKNOWN = 0, GP_STORAGEINFO_ST_FIXED_ROM = 1, GP_STORAGEINFO_ST_REMOVABLE_ROM = 2, GP_STORAGEINFO_ST_FIXED_RAM = 3,
  GP_STORAGEINFO_ST_REMOVABLE_RAM = 4
}
 Hardware storage types. More...
 
enum  CameraStorageAccessType { GP_STORAGEINFO_AC_READWRITE = 0, GP_STORAGEINFO_AC_READONLY = 1, GP_STORAGEINFO_AC_READONLY_WITH_DELETE = 2 }
 Storage access modes. More...
 
enum  CameraStorageFilesystemType { GP_STORAGEINFO_FST_UNDEFINED = 0, GP_STORAGEINFO_FST_GENERICFLAT = 1, GP_STORAGEINFO_FST_GENERICHIERARCHICAL = 2, GP_STORAGEINFO_FST_DCF = 3 }
 Filesystem hierarchy types. More...
 

Functions

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)
 
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. More...
 
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. 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_reset (CameraFilesystem *fs)
 Clear the filesystem. More...
 
int gp_filesystem_count (CameraFilesystem *fs, const char *folder, GPContext *context)
 Count files a folder of a 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_get_folder (CameraFilesystem *fs, const char *filename, char **folder, GPContext *context)
 Search a folder that contains a given filename. 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_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_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_info (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo info, GPContext *context)
 Set information about a file. 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_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. 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_get_storageinfo (CameraFilesystem *fs, CameraStorageInformation **, int *nrofstorageinformations, GPContext *context)
 Get the storage information about this filesystem. More...
 
int gp_filesystem_set_funcs (CameraFilesystem *fs, CameraFilesystemFuncs *funcs, void *data)
 Set all filesystem related function pointers. More...
 
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. More...
 
int gp_filesystem_delete_all (CameraFilesystem *fs, const char *folder, GPContext *context)
 Delete all files in specified folder. 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_dump (CameraFilesystem *fs)
 Dump the current filesystem. More...
 

Detailed Description

Filesystem related operations and declarations.

Author
Copyright 2000 Scott Fritzinger
Copyright 2008-2009 Marcus Meissner
Note
Contributions: Lutz Mueller lutz@.nosp@m.user.nosp@m.s.sf..nosp@m.net (2001)
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Typedef Documentation

File information structure.

Contains the normal, preview and audio file information structures for a specific file.

File information of an audio file.

Contains information of an audio file with fields being set depending on the bitmask in the fields member.

File information of a regular file.

Contains information a regular file with fields being set depending on the bitmask in the fields member.

File information of a preview file.

Contains information of a preview file with fields being set depending on the bitmask in the fields member.

Filesystem structure, only exposed to camera drivers.

Internal structure, contents not exposed to frontends. Camera drivers get these passed to filesystem related functions and are supposed to use it only via the accessor functions.

Storage information structue.

This structure contains the information of a specific camera storage. Only the members as specified by the fields member are valid.

Enumeration Type Documentation

Bitmask on what fields are set in the CameraFileInfo structure.

Bitmask to mark up which fields are set in the CameraFileInfo structure. The other fields might be uninitialized. If you set information via gp_camera_file_set_info() you need to set those flags. If you retrieve information via gp_camera_file_get_info() you need to check those flags. They are seperate for both "normal" and "preview" parts and are mostly image related.

Enumerator
GP_FILE_INFO_NONE 

No fields set.

GP_FILE_INFO_TYPE 

The MIME type is set.

GP_FILE_INFO_SIZE 

The filesize is set.

GP_FILE_INFO_WIDTH 

The width is set.

GP_FILE_INFO_HEIGHT 

The height is set.

GP_FILE_INFO_PERMISSIONS 

The access permissions are set.

GP_FILE_INFO_STATUS 

The status is set (downloaded).

GP_FILE_INFO_MTIME 

The modification time is set.

GP_FILE_INFO_ALL 

All possible fields set. Internal.

Bitmask containing the file permission flags.

Possible flag values of the permission entry in the file information.

Enumerator
GP_FILE_PERM_NONE 

No permissions.

GP_FILE_PERM_READ 

Read permissions.

GP_FILE_PERM_DELETE 

Write permissions.

GP_FILE_PERM_ALL 

Internal.

Possible status values.

Bitmask of possible stati. Currently only download is supported.

Enumerator
GP_FILE_STATUS_NOT_DOWNLOADED 

File is not downloaded.

GP_FILE_STATUS_DOWNLOADED 

File is already downloaded.

Storage access modes.

The modes we can access the storage with. Uses the same types and values as the PTP standard (PTP_AC_xxx).

Enumerator
GP_STORAGEINFO_AC_READWRITE 

Storage is Read / Write.

GP_STORAGEINFO_AC_READONLY 

Storage is Ready Only.

GP_STORAGEINFO_AC_READONLY_WITH_DELETE 

Storage is Ready Only, but allows Delete.

Filesystem hierarchy types.

The type of the filesystem hierarchy the devices uses. Same types and values as the PTP standard defines (PTP_FST_xxx).

Enumerator
GP_STORAGEINFO_FST_UNDEFINED 

Undefined or unknown filesystem hierarchy.

GP_STORAGEINFO_FST_GENERICFLAT 

Generic flat storage (all in 1 directory).

GP_STORAGEINFO_FST_GENERICHIERARCHICAL 

Generic tree hierarchy.

GP_STORAGEINFO_FST_DCF 

DCIM style storage.

Storage information flags.

Bitmask to specify which entries of the filesystem storage information is set.

Enumerator
GP_STORAGEINFO_BASE 

The base directory. Usually / if just 1 storage is attached.

GP_STORAGEINFO_LABEL 

Label of the filesystem. Could also be a DOS label.

GP_STORAGEINFO_DESCRIPTION 

More verbose description.

GP_STORAGEINFO_ACCESS 

Access permissions.

GP_STORAGEINFO_STORAGETYPE 

Hardware type.

GP_STORAGEINFO_FILESYSTEMTYPE 

Filesystem type.

GP_STORAGEINFO_MAXCAPACITY 

Maximum capacity in kbytes.

GP_STORAGEINFO_FREESPACEKBYTES 

Free space in kbytes.

GP_STORAGEINFO_FREESPACEIMAGES 

Free space in images.

Hardware storage types.

Type of hardware this storage is on. The types and values are the same as the PTP standard uses (PTP_ST_xxx).

Enumerator
GP_STORAGEINFO_ST_UNKNOWN 

Unknown storage type.

GP_STORAGEINFO_ST_FIXED_ROM 

A fixed ROM storage.

GP_STORAGEINFO_ST_REMOVABLE_ROM 

A removable ROM storage.

GP_STORAGEINFO_ST_FIXED_RAM 

A fixed RAM storage. (e.g. SDRAM)

GP_STORAGEINFO_ST_REMOVABLE_RAM 

A removable RAM storage. (any kind of cards etc)

Function Documentation

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

Count files a folder of a filesystem.

Parameters
fsa CameraFilesystem
foldera folder in which to count the files
contexta 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
fsa CameraFilesystem
folderthe folder in which to delete all files
contexta 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_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
fsa CameraFilesystem
foldera folder in which to delete the file
filenamethe name of the file to delete
contexta 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(), and gp_filesystem_dump().

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
fsa CameraFilesystem
foldera folder in which to delete the file
filenamethe name of the file to delete
contexta 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
fsthe CameraFilesystem
Returns
a gphoto error code

Internal function to dump the current filesystem.

References GP_ERROR, gp_file_unref(), gp_filesystem_delete_file(), gp_filesystem_list_files(), gp_list_count(), gp_list_free(), gp_list_get_name(), gp_list_new(), and GP_OK.

int gp_filesystem_free ( CameraFilesystem fs)

Free filesystem struct.

Parameters
fsa CameraFilesystem

Frees the CameraFilesystem

Returns
a gphoto2 error code.

References GP_ERROR_FILE_EXISTS, GP_ERROR_NO_MEMORY, gp_filesystem_list_files(), gp_filesystem_reset(), gp_list_free(), gp_list_new(), 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
fsa CameraFilesystem
folderthe folder in which the file can be found
filenamethe name of the file to download
typethe type of the file
filethe file that receives the data
contexta 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_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(), and gp_filesystem_read_file().

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

Search a folder that contains a given filename.

Parameters
fsa CameraFilesystem
filenamethe name of the file to search in the fs
folderpointer to value where the string is stored in
contexta 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, GP_ERROR_FILE_NOT_FOUND, GP_ERROR_NOT_SUPPORTED, gp_file_adjust_name_for_mime_type(), gp_file_copy(), gp_file_set_name(), 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_filesystem_set_file_noop(), 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
fsa CameraFilesystem
folderthe folder that contains the file
filenamethe filename
infopointer to CameraFileInfo that receives the information
contexta GPContext
Returns
a gphoto2 error code.

References _CameraFileInfoFile::fields, GP_ERROR, GP_ERROR_NOT_SUPPORTED, gp_file_get_data_and_size(), GP_FILE_INFO_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_OK, gp_setting_get(), gp_setting_set(), _CameraFileInfoFile::mtime, and PICTURES_TO_KEEP.

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
fsthe filesystem
storageinfoPointer to receive a pointer to/array of storage info items
nrofstorageinfosPointer to receive number of array entries
contexta 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
fsa CameraFilesystem
foldera folder of which a file list should be generated
lista CameraList where to put the list of files into
contexta 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_list_append(), gp_list_count(), gp_list_get_name(), gp_list_reset(), and GP_OK.

Referenced by gp_camera_folder_list_files(), gp_filesystem_dump(), gp_filesystem_free(), 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
fsa CameraFilesystem
foldera folder
lista CameraList where subfolders should be listed
contexta 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(), and GP_OK.

Referenced by gp_camera_folder_list_folders(), gp_filesystem_number(), 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
fsa CameraFilesystem
folderthe folder in which the directory should be created
namethe name of the directory to be created
contexta 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
fsa CameraFilesystem
folderthe folder where to look up the file with the filenumber
filenumberthe number of the file
filenamepointer to a filename where the result is stored
contexta 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
fsa 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
fsa CameraFilesystem
folderthe folder where to look for file called filename
filenamethe file to look for
contexta 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_list_folders(), gp_filesystem_number(), gp_list_count(), gp_list_free(), gp_list_get_name(), gp_list_new(), and GP_OK.

Referenced by gp_filesystem_number().

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.

Parameters
fsa CameraFilesystem
folderthe folder where to put the file into
filethe file
contexta 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, GP_ERROR_NOT_SUPPORTED, GP_FILE_TYPE_NORMAL, and GP_OK.

Referenced by gp_camera_folder_put_file().

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.

Parameters
fsa CameraFilesystem
folderthe folder in which the file can be found
filenamethe name of the file to download
typethe type of the file
offsetthe offset where the data starts
bufthe targetbuffer where the data will be put
sizethe size to read and that was read into the buffer
contexta GPContext

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

The file is read partially into the passed buffer. The read starts at offset on the device and goes for at most size bytes. Reading over the end of the file might give errors, so get the maximum file size via an info function before.

Returns
a gphoto2 error code.

References GP_ERROR_NOT_SUPPORTED, gp_file_get_data_and_size(), gp_file_new(), gp_file_unref(), gp_filesystem_get_file(), gp_filesystem_set_file_noop(), and GP_OK.

Referenced by gp_camera_file_read().

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

Remove a subfolder from within a folder.

Parameters
fsa CameraFilesystem
folderthe folder in which the directory should be created
namethe name of the directory to be created
contexta 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(), and GP_OK.

Referenced by gp_camera_folder_remove_dir().

int gp_filesystem_reset ( CameraFilesystem fs)

Clear the filesystem.

Parameters
fsthe 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_OK.

Referenced by gp_camera_exit(), and gp_filesystem_free().

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.

Parameters
fsa CameraFilesystem
foldera folder in the filesystem
filea CameraFile
contexta 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_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(), gp_filesystem_get_folder(), and gp_filesystem_read_file().

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

Set all filesystem related function pointers.

Parameters
fsa CameraFilesystem
funcspointer to a struct of filesystem functions
dataprivate 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
fsa CameraFilesystem
folderfoldername where the file resides
filenamethe files name
infothe CameraFileInfo to set
contexta 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_NOT_SUPPORTED, GP_FILE_INFO_HEIGHT, GP_FILE_INFO_PERMISSIONS, GP_FILE_INFO_SIZE, GP_FILE_INFO_STATUS, GP_FILE_INFO_TYPE, GP_FILE_INFO_WIDTH, GP_OK, and _CameraFileInfoFile::permissions.

Referenced by gp_camera_file_set_info().

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.

Parameters
fsa CameraFilesystem
folderthe foldername
infothe CameraFileInfo to store
contexta 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.