libgphoto2 photo camera library (libgphoto2) API
2.5.10.1
|
Abstracted gphoto2 file operations. More...
#include <time.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | _CameraFileHandler |
Macros | |
#define | GP_MIME_TXT "text/plain" |
#define | GP_MIME_WAV "audio/wav" |
#define | GP_MIME_RAW "image/x-raw" |
#define | GP_MIME_PNG "image/png" |
#define | GP_MIME_PGM "image/x-portable-graymap" |
#define | GP_MIME_PPM "image/x-portable-pixmap" |
#define | GP_MIME_PNM "image/x-portable-anymap" |
#define | GP_MIME_JPEG "image/jpeg" |
#define | GP_MIME_TIFF "image/tiff" |
#define | GP_MIME_BMP "image/bmp" |
#define | GP_MIME_QUICKTIME "video/quicktime" |
#define | GP_MIME_AVI "video/x-msvideo" |
#define | GP_MIME_CRW "image/x-canon-raw" |
#define | GP_MIME_CR2 "image/x-canon-cr2" |
#define | GP_MIME_NEF "image/x-nikon-nef" |
#define | GP_MIME_UNKNOWN "application/octet-stream" |
#define | GP_MIME_EXIF "application/x-exif" |
#define | GP_MIME_MP3 "audio/mpeg" |
#define | GP_MIME_OGG "application/ogg" |
#define | GP_MIME_WMA "audio/x-wma" |
#define | GP_MIME_ASF "audio/x-asf" |
#define | GP_MIME_MPEG "video/mpeg" |
#define | GP_MIME_AVCHD "video/mp2t" |
#define | GP_MIME_RW2 "image/x-panasonic-raw2" |
#define | GP_MIME_ARW "image/x-sony-arw" |
Typedefs | |
typedef struct _CameraFileHandler | CameraFileHandler |
typedef struct _CameraFile | CameraFile |
Enumerations | |
enum | CameraFileType { GP_FILE_TYPE_PREVIEW, GP_FILE_TYPE_NORMAL, GP_FILE_TYPE_RAW, GP_FILE_TYPE_AUDIO, GP_FILE_TYPE_EXIF, GP_FILE_TYPE_METADATA } |
The type of view on the specified file. More... | |
enum | CameraFileAccessType { GP_FILE_ACCESSTYPE_MEMORY, GP_FILE_ACCESSTYPE_FD, GP_FILE_ACCESSTYPE_HANDLER } |
File storage type. More... | |
Functions | |
int | gp_file_new (CameraFile **file) |
int | gp_file_new_from_fd (CameraFile **file, int fd) |
int | gp_file_new_from_handler (CameraFile **file, CameraFileHandler *handler, void *priv) |
int | gp_file_ref (CameraFile *file) |
Increase reference counter for CameraFile object. More... | |
int | gp_file_unref (CameraFile *file) |
Decrease reference counter for CameraFile object. More... | |
int | gp_file_free (CameraFile *file) |
descruct a CameraFile object. More... | |
int | gp_file_set_name (CameraFile *file, const char *name) |
int | gp_file_get_name (CameraFile *file, const char **name) |
int | gp_file_set_mime_type (CameraFile *file, const char *mime_type) |
int | gp_file_get_mime_type (CameraFile *file, const char **mime_type) |
int | gp_file_set_mtime (CameraFile *file, time_t mtime) |
int | gp_file_get_mtime (CameraFile *file, time_t *mtime) |
int | gp_file_detect_mime_type (CameraFile *file) |
int | gp_file_adjust_name_for_mime_type (CameraFile *file) |
int | gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType type, char **newname) |
int | gp_file_set_data_and_size (CameraFile *, char *data, unsigned long int size) |
int | gp_file_get_data_and_size (CameraFile *, const char **data, unsigned long int *size) |
int | gp_file_open (CameraFile *file, const char *filename) |
int | gp_file_save (CameraFile *file, const char *filename) |
int | gp_file_clean (CameraFile *file) |
int | gp_file_copy (CameraFile *destination, CameraFile *source) |
int | gp_file_append (CameraFile *, const char *data, unsigned long int size) |
int | gp_file_slurp (CameraFile *, char *data, size_t size, size_t *readlen) |
Abstracted gphoto2 file operations.
enum CameraFileAccessType |
File storage type.
The file storage type. Only used internally for now, but might be exposed later on. See gp_file_new() and gp_file_new_from_fd().
enum CameraFileType |
The type of view on the specified file.
Specifies the file of the current file, usually passed to the gp_camera_file_get() and gp_camera_file_put() functions. This is useful for multiple views of one file, like that an single image file has "raw", "normal", "exif" and "preview" views, or a media file has "normal" and "metadata" file views.
int gp_file_adjust_name_for_mime_type | ( | CameraFile * | file | ) |
file | a CameraFile |
References GP_OK.
Referenced by gp_filesystem_get_file(), and gp_filesystem_get_folder().
int gp_file_append | ( | CameraFile * | file, |
const char * | data, | ||
unsigned long int | size | ||
) |
file | a CameraFile |
data | |
size |
References GP_ERROR, GP_ERROR_IO_WRITE, GP_FILE_ACCESSTYPE_FD, GP_FILE_ACCESSTYPE_HANDLER, GP_FILE_ACCESSTYPE_MEMORY, and GP_OK.
int gp_file_clean | ( | CameraFile * | file | ) |
file | a CameraFile |
References GP_FILE_ACCESSTYPE_FD, GP_FILE_ACCESSTYPE_MEMORY, and GP_OK.
Referenced by gp_camera_capture_preview(), gp_camera_file_get(), gp_file_free(), and gp_file_open().
int gp_file_copy | ( | CameraFile * | destination, |
CameraFile * | source | ||
) |
destination | a CameraFile |
source | a CameraFile |
References GP_ERROR, GP_ERROR_IO, GP_ERROR_IO_READ, GP_ERROR_IO_WRITE, GP_FILE_ACCESSTYPE_FD, GP_FILE_ACCESSTYPE_HANDLER, GP_FILE_ACCESSTYPE_MEMORY, and GP_OK.
Referenced by gp_filesystem_get_folder().
int gp_file_detect_mime_type | ( | CameraFile * | file | ) |
file | a CameraFile |
References GP_ERROR_IO_READ, GP_FILE_ACCESSTYPE_FD, GP_FILE_ACCESSTYPE_MEMORY, gp_file_set_mime_type(), and GP_OK.
int gp_file_free | ( | CameraFile * | file | ) |
descruct a CameraFile object.
file | a CameraFile |
References GP_FILE_ACCESSTYPE_FD, gp_file_clean(), and GP_OK.
Referenced by gp_file_unref().
int gp_file_get_data_and_size | ( | CameraFile * | file, |
const char ** | data, | ||
unsigned long int * | size | ||
) |
Get a pointer to the data and the file's size.
file | a CameraFile |
data | |
size |
Both data and size can be NULL and will then be ignored.
The pointer to data that is returned is still owned by libgphoto2 and its lifetime is the same as the #file.
References GP_ERROR, GP_ERROR_IO, GP_ERROR_IO_READ, GP_FILE_ACCESSTYPE_FD, GP_FILE_ACCESSTYPE_HANDLER, GP_FILE_ACCESSTYPE_MEMORY, and GP_OK.
Referenced by gp_camera_file_get_info(), gp_filesystem_get_file(), gp_filesystem_get_info(), gp_filesystem_read_file(), and gp_filesystem_set_file_noop().
int gp_file_get_mime_type | ( | CameraFile * | file, |
const char ** | mime_type | ||
) |
file | a CameraFile |
mime_type | a pointer to a MIME type string |
References GP_OK.
Referenced by gp_camera_file_get_info().
int gp_file_get_mtime | ( | CameraFile * | file, |
time_t * | mtime | ||
) |
file | a CameraFile |
mtime |
References GP_OK.
Referenced by gp_filesystem_set_file_noop().
int gp_file_get_name | ( | CameraFile * | file, |
const char ** | name | ||
) |
file | a CameraFile |
name | a pointer to a name string |
References GP_OK.
int gp_file_get_name_by_type | ( | CameraFile * | file, |
const char * | basename, | ||
CameraFileType | type, | ||
char ** | newname | ||
) |
file | a CameraFile |
basename | the basename of the file |
type | the gphoto type of the file |
newname | the new name generated |
This function takes the basename and generates a filename out of it depending on the gphoto filetype and the mime type in the file. The gphoto filetype will be converted to a prefix, like thumb_ or raw_, the mimetype will replace the current suffix by a different one (if necessary).
This can be used so that saving thumbnails or metadata will not overwrite the normal files.
References GP_FILE_TYPE_AUDIO, GP_FILE_TYPE_EXIF, GP_FILE_TYPE_METADATA, GP_FILE_TYPE_NORMAL, GP_FILE_TYPE_PREVIEW, GP_FILE_TYPE_RAW, and GP_OK.
Referenced by gp_camera_capture_preview().
int gp_file_new | ( | CameraFile ** | file | ) |
Create new CameraFile object.
file | a pointer to a CameraFile |
References GP_FILE_ACCESSTYPE_MEMORY, and GP_OK.
Referenced by gp_camera_file_get_info(), gp_filesystem_get_file(), and gp_filesystem_read_file().
int gp_file_new_from_fd | ( | CameraFile ** | file, |
int | fd | ||
) |
Create new CameraFile object from a UNIX filedescriptor.
file | a pointer to a CameraFile |
fd | a UNIX filedescriptor |
References GP_FILE_ACCESSTYPE_FD, and GP_OK.
int gp_file_new_from_handler | ( | CameraFile ** | file, |
CameraFileHandler * | handler, | ||
void * | private | ||
) |
Create new CameraFile object using a programmatic handler.
file | a pointer to a CameraFile |
handler | a #CameraFileHandler |
private | a private pointer for frontend use |
References GP_FILE_ACCESSTYPE_HANDLER, and GP_OK.
int gp_file_open | ( | CameraFile * | file, |
const char * | filename | ||
) |
file | a CameraFile |
filename |
References GP_ERROR, GP_ERROR_NO_MEMORY, GP_FILE_ACCESSTYPE_FD, GP_FILE_ACCESSTYPE_MEMORY, gp_file_clean(), and GP_OK.
int gp_file_ref | ( | CameraFile * | file | ) |
Increase reference counter for CameraFile object.
file | a CameraFile |
References GP_OK.
Referenced by gp_filesystem_set_file_noop().
int gp_file_save | ( | CameraFile * | file, |
const char * | filename | ||
) |
file | a CameraFile |
filename |
References GP_ERROR, GP_ERROR_IO, GP_ERROR_IO_READ, GP_FILE_ACCESSTYPE_FD, GP_FILE_ACCESSTYPE_MEMORY, and GP_OK.
int gp_file_set_data_and_size | ( | CameraFile * | file, |
char * | data, | ||
unsigned long int | size | ||
) |
file | a CameraFile |
data | |
size |
References GP_ERROR, GP_ERROR_IO_WRITE, GP_FILE_ACCESSTYPE_FD, GP_FILE_ACCESSTYPE_HANDLER, GP_FILE_ACCESSTYPE_MEMORY, and GP_OK.
Referenced by gp_filesystem_get_file().
int gp_file_set_mime_type | ( | CameraFile * | file, |
const char * | mime_type | ||
) |
file | a CameraFile |
mime_type | a MIME type string |
References GP_OK.
Referenced by gp_file_detect_mime_type(), and gp_filesystem_get_file().
int gp_file_set_mtime | ( | CameraFile * | file, |
time_t | mtime | ||
) |
file | a CameraFile |
mtime |
References GP_OK.
Referenced by gp_filesystem_set_file_noop().
int gp_file_set_name | ( | CameraFile * | file, |
const char * | name | ||
) |
file | a CameraFile |
name | a pointer to a MIME type string |
References GP_OK.
Referenced by gp_camera_capture_preview(), gp_filesystem_get_file(), and gp_filesystem_get_folder().
int gp_file_slurp | ( | CameraFile * | file, |
char * | data, | ||
size_t | size, | ||
size_t * | readlen | ||
) |
file | a CameraFile |
data | |
size |
Internal.
References GP_ERROR, GP_ERROR_IO_READ, GP_FILE_ACCESSTYPE_FD, GP_FILE_ACCESSTYPE_HANDLER, GP_FILE_ACCESSTYPE_MEMORY, and GP_OK.
int gp_file_unref | ( | CameraFile * | file | ) |
Decrease reference counter for CameraFile object.
file | a CameraFile |
References gp_file_free(), and GP_OK.
Referenced by gp_camera_file_get_info(), gp_filesystem_dump(), gp_filesystem_get_file(), gp_filesystem_get_info(), gp_filesystem_read_file(), and gp_filesystem_set_file_noop().