libgphoto2 photo camera library (libgphoto2) Internals
2.5.23
|
#include "config.h"
#include <gphoto2/gphoto2-filesys.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <gphoto2/gphoto2-result.h>
#include <gphoto2/gphoto2-port-log.h>
#include <gphoto2/gphoto2-setting.h>
#include <limits.h>
Go to the source code of this file.
Data Structures | |
struct | _CameraFilesystemFile |
struct | _CameraFilesystemFolder |
struct | _CameraFilesystem |
The internal camera filesystem structure. More... | |
Macros | |
#define | _DEFAULT_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 | PATH_MAX 4096 |
#define | PICTURES_TO_KEEP 2 |
#define | MIN(a, b) (((a) < (b)) ? (a) : (b)) |
#define | CR(result) {int __r = (result); if (__r < 0) return (__r);} |
#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 | |
static int | gp_filesystem_lru_clear (CameraFilesystem *fs) |
static int | gp_filesystem_lru_remove_one (CameraFilesystem *fs, CameraFilesystemFile *item) |
static int | gp_filesystem_lru_update (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, GPContext *context) |
static int | delete_all_files (CameraFilesystem *fs, CameraFilesystemFolder *folder) |
static int | delete_folder (CameraFilesystem *fs, CameraFilesystemFolder **folder) |
static CameraFilesystemFolder * | lookup_folder (CameraFilesystem *fs, CameraFilesystemFolder *folder, const char *foldername, GPContext *context) |
static int | lookup_folder_file (CameraFilesystem *fs, const char *folder, const char *filename, CameraFilesystemFolder **xfolder, CameraFilesystemFile **xfile, GPContext *context) |
static int | recurse_delete_folder (CameraFilesystem *fs, CameraFilesystemFolder *folder) |
static int | delete_all_folders (CameraFilesystem *fs, const char *foldername, GPContext *context) |
static int | append_folder_one (CameraFilesystemFolder *folder, const char *name, CameraFilesystemFolder **newfolder) |
static int | append_to_folder (CameraFilesystemFolder *folder, const char *foldername, CameraFilesystemFolder **newfolder) |
static int | append_folder (CameraFilesystem *fs, const char *folder, CameraFilesystemFolder **newfolder, GPContext *context) |
static int | append_file (CameraFilesystem *fs, CameraFilesystemFolder *folder, const char *name, CameraFile *file, GPContext *context) |
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... | |
static int | internal_append (CameraFilesystem *fs, CameraFilesystemFolder *f, const char *filename, GPContext *context) |
Append a file to a folder in a filesystem. More... | |
int | gp_filesystem_append (CameraFilesystem *fs, const char *folder, const char *filename, GPContext *context) |
static void | recursive_fs_dump (CameraFilesystemFolder *folder, int depth) |
int | gp_filesystem_dump (CameraFilesystem *fs) |
Dump the current filesystem. More... | |
static int | delete_file (CameraFilesystem *fs, CameraFilesystemFolder *folder, CameraFilesystemFile *file) |
static int | gp_filesystem_delete_all_one_by_one (CameraFilesystem *fs, const char *folder, GPContext *context) |
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, const char *filename, CameraFileType type, 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... | |
static int | gp_filesystem_scan (CameraFilesystem *fs, const char *folder, const char *filename, GPContext *context) |
static int | recursive_folder_scan (CameraFilesystemFolder *folder, const char *lookforfile, char **foldername) |
int | gp_filesystem_get_folder (CameraFilesystem *fs, const char *filename, char **folder, GPContext *context) |
Search a folder that contains a given filename. More... | |
static int | gp_filesystem_get_file_impl (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, GPContext *context) |
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_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... | |
static int | gp_filesystem_lru_free (CameraFilesystem *fs) |
static int | gp_filesystem_lru_count (CameraFilesystem *fs) |
static int | gp_filesystem_lru_check (CameraFilesystem *fs) |
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_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_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... | |
Variables | |
static int | pictures_to_keep = -1 |
Definition in file gphoto2-filesys.c.
#define _ | ( | String | ) | (String) |
Definition at line 61 of file gphoto2-filesys.c.
#define _DEFAULT_SOURCE |
Definition at line 27 of file gphoto2-filesys.c.
#define bindtextdomain | ( | Domain, | |
Directory | |||
) | (Domain) |
Definition at line 60 of file gphoto2-filesys.c.
#define CA | ( | f, | |
c | |||
) |
Definition at line 297 of file gphoto2-filesys.c.
#define CC | ( | context | ) |
Definition at line 291 of file gphoto2-filesys.c.
#define CL | ( | result, | |
list | |||
) |
Definition at line 271 of file gphoto2-filesys.c.
Definition at line 269 of file gphoto2-filesys.c.
#define CU | ( | result, | |
file | |||
) |
Definition at line 281 of file gphoto2-filesys.c.
#define dcgettext | ( | Domain, | |
Message, | |||
Type | |||
) | (Message) |
Definition at line 59 of file gphoto2-filesys.c.
#define dgettext | ( | Domain, | |
Message | |||
) | (Message) |
Definition at line 58 of file gphoto2-filesys.c.
#define gettext | ( | String | ) | (String) |
Definition at line 57 of file gphoto2-filesys.c.
#define MIN | ( | a, | |
b | |||
) | (((a) < (b)) ? (a) : (b)) |
Definition at line 267 of file gphoto2-filesys.c.
#define N_ | ( | String | ) | (String) |
Definition at line 62 of file gphoto2-filesys.c.
#define PATH_MAX 4096 |
Definition at line 66 of file gphoto2-filesys.c.
#define PICTURES_TO_KEEP 2 |
The default number of pictures to keep in the internal cache, can be overriden by settings.
Definition at line 103 of file gphoto2-filesys.c.
#define textdomain | ( | String | ) | (String) |
Definition at line 56 of file gphoto2-filesys.c.
typedef struct _CameraFilesystemFile CameraFilesystemFile |
typedef struct _CameraFilesystemFolder CameraFilesystemFolder |
|
static |
Definition at line 596 of file gphoto2-filesys.c.
References _CameraFilesystemFolder::files, GP_ERROR, gp_file_ref(), and GP_OK.
Referenced by gp_filesystem_put_file().
|
static |
Definition at line 582 of file gphoto2-filesys.c.
References append_to_folder(), CA, CC, and _CameraFilesystem::rootfolder.
Referenced by gp_filesystem_append().
|
static |
Definition at line 509 of file gphoto2-filesys.c.
References _CameraFilesystemFolder::files_dirty, _CameraFilesystemFolder::folders, _CameraFilesystemFolder::folders_dirty, GP_ERROR_NO_MEMORY, GP_OK, _CameraFilesystemFolder::name, and _CameraFilesystemFolder::next.
Referenced by append_to_folder(), gp_filesystem_list_folders(), and gp_filesystem_make_dir().
|
static |
Definition at line 535 of file gphoto2-filesys.c.
References append_folder_one(), CR, _CameraFilesystemFolder::folders, GP_OK, _CameraFilesystemFolder::name, and _CameraFilesystemFolder::next.
Referenced by append_folder().
|
static |
Definition at line 306 of file gphoto2-filesys.c.
References _CameraFilesystemFile::audio, _CameraFilesystemFile::exif, _CameraFilesystemFolder::files, gp_file_unref(), gp_filesystem_lru_remove_one(), GP_OK, _CameraFilesystemFile::metadata, _CameraFilesystemFile::name, _CameraFilesystemFolder::name, _CameraFilesystemFile::next, _CameraFilesystemFile::normal, _CameraFilesystemFile::preview, and _CameraFilesystemFile::raw.
Referenced by delete_folder(), gp_filesystem_delete_all(), and gp_filesystem_list_files().
|
static |
Definition at line 490 of file gphoto2-filesys.c.
References CA, CC, GP_OK, lookup_folder(), recurse_delete_folder(), and _CameraFilesystem::rootfolder.
Referenced by gp_filesystem_list_folders(), and gp_filesystem_reset().
|
static |
Definition at line 813 of file gphoto2-filesys.c.
References _CameraFilesystemFile::audio, _CameraFilesystemFile::exif, _CameraFilesystemFolder::files, GP_ERROR, gp_file_unref(), gp_filesystem_lru_remove_one(), GP_OK, _CameraFilesystemFile::metadata, _CameraFilesystemFile::name, _CameraFilesystemFile::next, _CameraFilesystemFile::normal, _CameraFilesystemFile::preview, and _CameraFilesystemFile::raw.
Referenced by gp_filesystem_delete_file(), and gp_filesystem_delete_file_noop().
|
static |
Definition at line 352 of file gphoto2-filesys.c.
References delete_all_files(), GP_OK, _CameraFilesystemFolder::name, and _CameraFilesystemFolder::next.
Referenced by gp_filesystem_remove_dir(), and recurse_delete_folder().
int gp_filesystem_append | ( | CameraFilesystem * | fs, |
const char * | folder, | ||
const char * | filename, | ||
GPContext * | context | ||
) |
Definition at line 743 of file gphoto2-filesys.c.
References append_folder(), CA, CC, CR, _CameraFilesystemFolder::files_dirty, GP_ERROR_FILE_EXISTS, gp_filesystem_list_files(), gp_list_free(), gp_list_new(), GP_OK, internal_append(), lookup_folder(), and _CameraFilesystem::rootfolder.
int gp_filesystem_count | ( | CameraFilesystem * | fs, |
const char * | folder, | ||
GPContext * | context | ||
) |
Count files a folder of a filesystem.
fs | a CameraFilesystem |
folder | a folder in which to count the files |
context | a GPContext |
Counts the files in the folder.
Definition at line 1076 of file gphoto2-filesys.c.
References CA, CC, _CameraFilesystemFolder::files, GP_ERROR_DIRECTORY_NOT_FOUND, lookup_folder(), _CameraFilesystemFile::next, and _CameraFilesystem::rootfolder.
int gp_filesystem_delete_all | ( | CameraFilesystem * | fs, |
const char * | folder, | ||
GPContext * | context | ||
) |
Delete all files in specified folder.
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.
Definition at line 891 of file gphoto2-filesys.c.
References CA, CC, CR, _CameraFilesystem::data, delete_all_files(), _CameraFilesystem::delete_all_func, _CameraFilesystemFolder::files_dirty, GP_ERROR_DIRECTORY_NOT_FOUND, gp_filesystem_delete_all_one_by_one(), GP_OK, gp_result_as_string(), lookup_folder(), and _CameraFilesystem::rootfolder.
Referenced by gp_camera_folder_delete_all().
|
static |
Definition at line 857 of file gphoto2-filesys.c.
References CL, CR, gp_filesystem_delete_file(), gp_filesystem_list_files(), gp_list_count(), gp_list_free(), gp_list_get_name(), gp_list_new(), and GP_OK.
Referenced by gp_filesystem_delete_all().
int gp_filesystem_delete_file | ( | CameraFilesystem * | fs, |
const char * | folder, | ||
const char * | filename, | ||
GPContext * | context | ||
) |
Delete a file from a folder.
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.
Definition at line 1113 of file gphoto2-filesys.c.
References _, CA, CC, CR, _CameraFilesystem::data, delete_file(), _CameraFilesystem::delete_file_func, gp_context_error(), GP_ERROR_NOT_SUPPORTED, GP_OK, and lookup_folder_file().
Referenced by gp_camera_file_delete(), and gp_filesystem_delete_all_one_by_one().
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.
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.
Definition at line 1157 of file gphoto2-filesys.c.
References CA, CC, CR, delete_file(), and lookup_folder_file().
int gp_filesystem_dump | ( | CameraFilesystem * | fs | ) |
Dump the current filesystem.
fs | the CameraFilesystem |
Internal function to dump the current filesystem.
Definition at line 805 of file gphoto2-filesys.c.
References GP_OK, recursive_fs_dump(), and _CameraFilesystem::rootfolder.
int gp_filesystem_free | ( | CameraFilesystem * | fs | ) |
Free filesystem struct.
fs | a CameraFilesystem |
Frees the CameraFilesystem
Definition at line 686 of file gphoto2-filesys.c.
References gp_filesystem_reset(), GP_OK, _CameraFilesystemFolder::name, and _CameraFilesystem::rootfolder.
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.
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.
Definition at line 1634 of file gphoto2-filesys.c.
References CR, CU, 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_get_file_impl(), gp_filesystem_set_file_noop(), GP_MIME_EXIF, GP_MIME_JPEG, GP_OK, and gp_result_as_string().
Referenced by gp_camera_file_get(), and gp_filesystem_read_file().
|
static |
Definition at line 1532 of file gphoto2-filesys.c.
References _, _CameraFilesystemFile::audio, CA, CC, CR, _CameraFilesystem::data, _CameraFilesystemFile::exif, _CameraFilesystem::get_file_func, gp_context_error(), GP_ERROR, 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(), GP_OK, lookup_folder_file(), _CameraFilesystemFile::metadata, _CameraFilesystemFile::normal, _CameraFilesystemFile::preview, and _CameraFilesystemFile::raw.
Referenced by gp_filesystem_get_file().
int gp_filesystem_get_folder | ( | CameraFilesystem * | fs, |
const char * | filename, | ||
char ** | folder, | ||
GPContext * | context | ||
) |
Search a folder that contains a given filename.
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.
Definition at line 1515 of file gphoto2-filesys.c.
References _, CC, CR, gp_context_error(), GP_ERROR_FILE_NOT_FOUND, gp_filesystem_scan(), GP_OK, recursive_folder_scan(), and _CameraFilesystem::rootfolder.
int gp_filesystem_get_info | ( | CameraFilesystem * | fs, |
const char * | folder, | ||
const char * | filename, | ||
CameraFileInfo * | info, | ||
GPContext * | context | ||
) |
Get information about the specified file.
fs | a CameraFilesystem |
folder | the folder that contains the file |
filename | the filename |
info | pointer to CameraFileInfo that receives the information |
context | a GPContext |
Definition at line 1857 of file gphoto2-filesys.c.
References _, CA, CC, CR, _CameraFilesystem::data, _CameraFileInfoFile::fields, _CameraFileInfo::file, _CameraFilesystem::get_info_func, gp_context_error(), GP_ERROR_NOT_SUPPORTED, GP_FILE_INFO_MTIME, GP_OK, _CameraFilesystemFile::info, _CameraFilesystemFile::info_dirty, lookup_folder_file(), 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.
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.
Definition at line 2449 of file gphoto2-filesys.c.
References _, CC, _CameraFilesystem::data, gp_context_error(), GP_ERROR_NOT_SUPPORTED, and _CameraFilesystem::storage_info_func.
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.
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.
Definition at line 952 of file gphoto2-filesys.c.
References CA, CC, CR, _CameraFilesystem::data, delete_all_files(), _CameraFilesystem::file_list_func, _CameraFilesystemFolder::files, _CameraFilesystemFolder::files_dirty, GP_ERROR_DIRECTORY_NOT_FOUND, gp_list_append(), gp_list_count(), gp_list_get_name(), gp_list_reset(), GP_OK, internal_append(), lookup_folder(), _CameraFilesystemFile::name, _CameraFilesystemFile::next, and _CameraFilesystem::rootfolder.
Referenced by gp_camera_folder_list_files(), gp_filesystem_append(), gp_filesystem_delete_all_one_by_one(), gp_filesystem_number(), gp_filesystem_scan(), and lookup_folder_file().
int gp_filesystem_list_folders | ( | CameraFilesystem * | fs, |
const char * | folder, | ||
CameraList * | list, | ||
GPContext * | context | ||
) |
List all subfolders within a filesystem folder.
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).
Definition at line 1018 of file gphoto2-filesys.c.
References append_folder_one(), CA, CC, CR, _CameraFilesystem::data, delete_all_folders(), _CameraFilesystem::folder_list_func, _CameraFilesystemFolder::folders, _CameraFilesystemFolder::folders_dirty, GP_ERROR_DIRECTORY_NOT_FOUND, gp_list_append(), gp_list_count(), gp_list_get_name(), gp_list_reset(), GP_OK, lookup_folder(), and _CameraFilesystem::rootfolder.
Referenced by gp_camera_folder_list_folders(), gp_filesystem_remove_dir(), gp_filesystem_scan(), and lookup_folder().
|
static |
Definition at line 2156 of file gphoto2-filesys.c.
References GP_ERROR, GP_OK, _CameraFilesystem::lru_first, _CameraFilesystemFile::lru_next, _CameraFilesystemFile::lru_prev, and _CameraFilesystem::lru_size.
Referenced by gp_filesystem_set_file_noop().
|
static |
Definition at line 1910 of file gphoto2-filesys.c.
References GP_ERROR, GP_OK, _CameraFilesystem::lru_first, _CameraFilesystem::lru_last, _CameraFilesystemFile::lru_next, _CameraFilesystemFile::lru_prev, and _CameraFilesystem::lru_size.
Referenced by gp_filesystem_reset().
|
static |
Definition at line 2026 of file gphoto2-filesys.c.
References _CameraFilesystemFile::audio, _CameraFilesystem::lru_first, _CameraFilesystemFile::lru_next, _CameraFilesystemFile::normal, and _CameraFilesystemFile::raw.
Referenced by gp_filesystem_lru_update().
|
static |
Definition at line 1984 of file gphoto2-filesys.c.
References _CameraFilesystemFile::audio, CR, gp_file_get_data_and_size(), gp_file_unref(), GP_OK, _CameraFilesystem::lru_first, _CameraFilesystem::lru_last, _CameraFilesystemFile::lru_next, _CameraFilesystemFile::lru_prev, _CameraFilesystem::lru_size, _CameraFilesystemFile::name, _CameraFilesystemFile::normal, and _CameraFilesystemFile::raw.
Referenced by gp_filesystem_lru_update().
|
static |
Definition at line 1946 of file gphoto2-filesys.c.
References GP_ERROR, GP_OK, _CameraFilesystem::lru_first, _CameraFilesystem::lru_last, _CameraFilesystemFile::lru_next, and _CameraFilesystemFile::lru_prev.
Referenced by delete_all_files(), delete_file(), and gp_filesystem_lru_update().
|
static |
Definition at line 2042 of file gphoto2-filesys.c.
References _, _CameraFilesystemFile::audio, CR, gp_context_error(), GP_ERROR, gp_file_get_data_and_size(), 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_lru_count(), gp_filesystem_lru_free(), gp_filesystem_lru_remove_one(), GP_OK, gp_setting_get(), gp_setting_set(), lookup_folder_file(), _CameraFilesystem::lru_first, _CameraFilesystem::lru_last, _CameraFilesystemFile::lru_next, _CameraFilesystemFile::lru_prev, _CameraFilesystem::lru_size, _CameraFilesystemFile::normal, PICTURES_TO_KEEP, pictures_to_keep, and _CameraFilesystemFile::raw.
Referenced by gp_filesystem_set_file_noop().
int gp_filesystem_make_dir | ( | CameraFilesystem * | fs, |
const char * | folder, | ||
const char * | name, | ||
GPContext * | context | ||
) |
Create a subfolder within a 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 |
Creates a new directory called name in given folder.
Definition at line 1183 of file gphoto2-filesys.c.
References append_folder_one(), CA, CC, CR, _CameraFilesystem::data, GP_ERROR_DIRECTORY_NOT_FOUND, GP_ERROR_NOT_SUPPORTED, lookup_folder(), _CameraFilesystem::make_dir_func, and _CameraFilesystem::rootfolder.
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.
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.
Definition at line 1338 of file gphoto2-filesys.c.
References _, CA, CC, _CameraFilesystemFolder::files, gp_context_error(), GP_ERROR_DIRECTORY_NOT_FOUND, GP_ERROR_FILE_NOT_FOUND, GP_OK, lookup_folder(), _CameraFilesystemFile::name, _CameraFilesystemFile::next, and _CameraFilesystem::rootfolder.
int gp_filesystem_new | ( | CameraFilesystem ** | fs | ) |
Create a new filesystem struct.
fs | a pointer to a CameraFilesystem |
Creates a new empty CameraFilesystem
Definition at line 655 of file gphoto2-filesys.c.
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.
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.
Definition at line 1384 of file gphoto2-filesys.c.
References _, CA, CC, CL, CR, _CameraFilesystemFolder::files, _CameraFilesystemFolder::files_dirty, gp_context_error(), GP_ERROR_DIRECTORY_NOT_FOUND, GP_ERROR_FILE_NOT_FOUND, gp_filesystem_list_files(), gp_filesystem_number(), gp_list_free(), gp_list_new(), lookup_folder(), _CameraFilesystemFile::name, _CameraFilesystemFile::next, and _CameraFilesystem::rootfolder.
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.
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.
Definition at line 1292 of file gphoto2-filesys.c.
References _, append_file(), CA, CC, CR, _CameraFilesystem::data, gp_context_error(), GP_ERROR_DIRECTORY_NOT_FOUND, GP_ERROR_NOT_SUPPORTED, GP_FILE_TYPE_NORMAL, GP_OK, lookup_folder(), _CameraFilesystem::put_file_func, and _CameraFilesystem::rootfolder.
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.
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 |
offset | the offset where the data starts |
buf | the targetbuffer where the data will be put |
size | the size to read and that was read into the buffer |
context | a 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.
Definition at line 1767 of file gphoto2-filesys.c.
References CA, CC, CR, _CameraFilesystem::data, 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(), GP_OK, and _CameraFilesystem::read_file_func.
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.
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.
Definition at line 1217 of file gphoto2-filesys.c.
References _, CA, CC, CR, _CameraFilesystem::data, delete_folder(), _CameraFilesystemFolder::folders, _CameraFilesystemFolder::folders_dirty, gp_context_error(), 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_OK, lookup_folder(), _CameraFilesystem::remove_dir_func, and _CameraFilesystem::rootfolder.
Referenced by gp_camera_folder_remove_dir().
int gp_filesystem_reset | ( | CameraFilesystem * | fs | ) |
Clear the filesystem.
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.
Definition at line 631 of file gphoto2-filesys.c.
References CR, delete_all_folders(), _CameraFilesystemFolder::files_dirty, _CameraFilesystemFolder::folders_dirty, gp_filesystem_lru_clear(), GP_OK, and _CameraFilesystem::rootfolder.
Referenced by gp_camera_exit(), and gp_filesystem_free().
|
static |
Definition at line 1422 of file gphoto2-filesys.c.
References CA, CC, CL, CR, gp_filesystem_list_files(), gp_filesystem_list_folders(), gp_list_count(), gp_list_free(), gp_list_get_name(), gp_list_new(), and GP_OK.
Referenced by gp_filesystem_get_folder().
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.
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().
Definition at line 2200 of file gphoto2-filesys.c.
References _, _CameraFilesystemFile::audio, CA, CC, CR, _CameraFilesystemFile::exif, _CameraFileInfoFile::fields, _CameraFileInfo::file, gp_context_error(), 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_filesystem_lru_check(), gp_filesystem_lru_update(), GP_OK, lookup_folder_file(), _CameraFilesystemFile::metadata, _CameraFileInfoFile::mtime, _CameraFilesystemFile::normal, _CameraFilesystemFile::preview, and _CameraFilesystemFile::raw.
Referenced by gp_filesystem_get_file(), gp_filesystem_get_file_impl(), and gp_filesystem_read_file().
int gp_filesystem_set_funcs | ( | CameraFilesystem * | fs, |
CameraFilesystemFuncs * | funcs, | ||
void * | data | ||
) |
Set all filesystem related function pointers.
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.
Definition at line 1824 of file gphoto2-filesys.c.
References _CameraFilesystem::data, _CameraFilesystemFuncs::del_file_func, _CameraFilesystem::delete_all_func, _CameraFilesystemFuncs::delete_all_func, _CameraFilesystem::delete_file_func, _CameraFilesystem::file_list_func, _CameraFilesystemFuncs::file_list_func, _CameraFilesystem::folder_list_func, _CameraFilesystemFuncs::folder_list_func, _CameraFilesystem::get_file_func, _CameraFilesystemFuncs::get_file_func, _CameraFilesystem::get_info_func, _CameraFilesystemFuncs::get_info_func, GP_OK, _CameraFilesystem::make_dir_func, _CameraFilesystemFuncs::make_dir_func, _CameraFilesystem::put_file_func, _CameraFilesystemFuncs::put_file_func, _CameraFilesystem::read_file_func, _CameraFilesystemFuncs::read_file_func, _CameraFilesystem::remove_dir_func, _CameraFilesystemFuncs::remove_dir_func, _CameraFilesystem::set_info_func, _CameraFilesystemFuncs::set_info_func, _CameraFilesystem::storage_info_func, and _CameraFilesystemFuncs::storage_info_func.
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.
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.
Definition at line 2367 of file gphoto2-filesys.c.
References _, _CameraFileInfo::audio, CA, CC, CR, _CameraFilesystem::data, _CameraFileInfoFile::fields, _CameraFileInfoPreview::fields, _CameraFileInfoAudio::fields, _CameraFileInfo::file, gp_context_error(), 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, _CameraFilesystemFile::info, _CameraFilesystemFile::info_dirty, lookup_folder_file(), _CameraFileInfoFile::permissions, _CameraFileInfo::preview, result, and _CameraFilesystem::set_info_func.
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.
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.
Definition at line 2335 of file gphoto2-filesys.c.
References CA, CC, CR, GP_OK, _CameraFilesystemFile::info, _CameraFilesystemFile::info_dirty, and lookup_folder_file().
|
static |
Append a file to a folder in a filesystem.
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.
Definition at line 714 of file gphoto2-filesys.c.
References _CameraFilesystemFolder::files, GP_ERROR_FILE_EXISTS, GP_ERROR_NO_MEMORY, GP_OK, and _CameraFilesystemFolder::name.
Referenced by gp_filesystem_append(), and gp_filesystem_list_files().
|
static |
Definition at line 367 of file gphoto2-filesys.c.
References _CameraFilesystemFolder::folders, _CameraFilesystemFolder::folders_dirty, gp_filesystem_list_folders(), gp_list_free(), gp_list_new(), GP_OK, _CameraFilesystemFolder::name, and _CameraFilesystemFolder::next.
Referenced by delete_all_folders(), gp_filesystem_append(), gp_filesystem_count(), gp_filesystem_delete_all(), gp_filesystem_list_files(), gp_filesystem_list_folders(), gp_filesystem_make_dir(), gp_filesystem_name(), gp_filesystem_number(), gp_filesystem_put_file(), gp_filesystem_remove_dir(), and lookup_folder_file().
|
static |
Definition at line 432 of file gphoto2-filesys.c.
References _CameraFilesystemFolder::files, _CameraFilesystemFolder::files_dirty, GP_ERROR_DIRECTORY_NOT_FOUND, GP_ERROR_FILE_NOT_FOUND, gp_filesystem_list_files(), gp_list_free(), gp_list_new(), GP_OK, lookup_folder(), _CameraFilesystemFile::name, _CameraFilesystemFile::next, and _CameraFilesystem::rootfolder.
Referenced by gp_filesystem_delete_file(), gp_filesystem_delete_file_noop(), gp_filesystem_get_file_impl(), gp_filesystem_get_info(), gp_filesystem_lru_update(), gp_filesystem_set_file_noop(), gp_filesystem_set_info(), and gp_filesystem_set_info_noop().
|
static |
Definition at line 477 of file gphoto2-filesys.c.
References delete_folder(), _CameraFilesystemFolder::folders, GP_OK, and _CameraFilesystemFolder::name.
Referenced by delete_all_folders().
|
static |
Definition at line 1462 of file gphoto2-filesys.c.
References _CameraFilesystemFolder::files, _CameraFilesystemFolder::folders, GP_ERROR_FILE_NOT_FOUND, GP_OK, _CameraFilesystemFile::name, _CameraFilesystemFolder::name, _CameraFilesystemFile::next, and _CameraFilesystemFolder::next.
Referenced by gp_filesystem_get_folder().
|
static |
Definition at line 779 of file gphoto2-filesys.c.
References _CameraFilesystemFolder::files, _CameraFilesystemFolder::folders, _CameraFilesystemFile::name, _CameraFilesystemFolder::name, _CameraFilesystemFile::next, and _CameraFilesystemFolder::next.
Referenced by gp_filesystem_dump().
|
static |
The current number of pictures to keep in the internal cache, either from PICTURES_TO_KEEP or from the settings.
Definition at line 107 of file gphoto2-filesys.c.
Referenced by gp_filesystem_lru_update().