summaryrefslogtreecommitdiff
path: root/libgphoto2
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2009-01-25 20:30:53 +0000
committerMarcus Meissner <marcus@jet.franken.de>2009-01-25 20:30:53 +0000
commita3ee73043c5dc7c28b5717fd971917627a7214f2 (patch)
tree4249bb9b1b0debbe19c6df749f8d045bcc39a055 /libgphoto2
parentccd327a379d7885389f57f0e8304c4cce948921f (diff)
downloadlibgphoto2-a3ee73043c5dc7c28b5717fd971917627a7214f2.tar.gz
* removed CameraFileInfoFile.name, adjusted users
and callers. * added filename argument to put_file_func, set_info_noop and set_file_noop functions. adjusted all camlibs git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@11773 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'libgphoto2')
-rw-r--r--libgphoto2/gphoto2-camera.c10
-rw-r--r--libgphoto2/gphoto2-filesys.c62
2 files changed, 20 insertions, 52 deletions
diff --git a/libgphoto2/gphoto2-camera.c b/libgphoto2/gphoto2-camera.c
index 5dcf2338d..a4ecb69f9 100644
--- a/libgphoto2/gphoto2-camera.c
+++ b/libgphoto2/gphoto2-camera.c
@@ -1145,7 +1145,8 @@ gp_camera_folder_delete_all (Camera *camera, const char *folder,
*
**/
int
-gp_camera_folder_put_file (Camera *camera, const char *folder,
+gp_camera_folder_put_file (Camera *camera,
+ const char *folder, const char *filename,
CameraFile *file, GPContext *context)
{
gp_log (GP_LOG_DEBUG, "gphoto2-camera", "Uploading file into '%s'...",
@@ -1155,7 +1156,7 @@ gp_camera_folder_put_file (Camera *camera, const char *folder,
CHECK_INIT (camera, context);
CHECK_RESULT_OPEN_CLOSE (camera, gp_filesystem_put_file (camera->fs,
- folder, file, context), context);
+ folder, filename, file, context), context);
CAMERA_UNUSED (camera, context);
return (GP_OK);
@@ -1224,11 +1225,6 @@ gp_camera_file_get_info (Camera *camera, const char *folder,
}
gp_file_unref (cfile);
- /* We don't trust the camera libraries */
- info->file.fields |= GP_FILE_INFO_NAME;
- strncpy (info->file.name, file, sizeof (info->file.name));
- info->preview.fields &= ~GP_FILE_INFO_NAME;
-
CAMERA_UNUSED (camera, context);
return (GP_OK);
}
diff --git a/libgphoto2/gphoto2-filesys.c b/libgphoto2/gphoto2-filesys.c
index 77a18b9c9..d571ab082 100644
--- a/libgphoto2/gphoto2-filesys.c
+++ b/libgphoto2/gphoto2-filesys.c
@@ -570,14 +570,12 @@ append_folder (CameraFilesystem *fs,
}
static int
-append_file (CameraFilesystem *fs, CameraFilesystemFolder *folder, CameraFile *file, GPContext *context)
+append_file (CameraFilesystem *fs, CameraFilesystemFolder *folder, const char *name, CameraFile *file, GPContext *context)
{
CameraFilesystemFile *new;
- const char *name;
CHECK_NULL (fs && file);
- CR (gp_file_get_name (file, &name));
gp_log (GP_LOG_DEBUG, "gphoto2-filesystem", "Appending file %s...", name);
new = folder->files;
@@ -1228,7 +1226,8 @@ gp_filesystem_remove_dir (CameraFilesystem *fs, const char *folder,
* \return a gphoto2 error code.
**/
int
-gp_filesystem_put_file (CameraFilesystem *fs, const char *folder,
+gp_filesystem_put_file (CameraFilesystem *fs,
+ const char *folder, const char *filename,
CameraFile *file, GPContext *context)
{
CameraFilesystemFolder *f;
@@ -1249,9 +1248,9 @@ gp_filesystem_put_file (CameraFilesystem *fs, const char *folder,
if (!f) return (GP_ERROR_DIRECTORY_NOT_FOUND);
/* Upload the file */
- CR (fs->put_file_func (fs, folder, file, fs->folder_data, context));
+ CR (fs->put_file_func (fs, folder, filename, file, fs->folder_data, context));
/* And upload it to internal structure too */
- return append_file (fs, f, file, context);
+ return append_file (fs, f, filename, file, context);
}
/**
@@ -1631,7 +1630,7 @@ gp_filesystem_get_file_impl (CameraFilesystem *fs, const char *folder,
CR (gp_file_set_name (file, filename));
/* Cache this file */
- CR (gp_filesystem_set_file_noop (fs, folder, file, context));
+ CR (gp_filesystem_set_file_noop (fs, folder, filename, file, context));
/*
* Often, thumbnails are of a different mime type than the normal
@@ -1719,7 +1718,7 @@ gp_filesystem_get_file (CameraFilesystem *fs, const char *folder,
CR (gp_file_set_type (file, GP_FILE_TYPE_PREVIEW));
CR (gp_file_set_name (file, filename));
CR (gp_file_set_mime_type (file, GP_MIME_JPEG));
- CR (gp_filesystem_set_file_noop (fs, folder, file, context));
+ CR (gp_filesystem_set_file_noop (fs, folder, filename, file, context));
CR (gp_file_adjust_name_for_mime_type (file));
#else
GP_DEBUG ("Getting previews is not supported and "
@@ -1758,7 +1757,7 @@ gp_filesystem_get_file (CameraFilesystem *fs, const char *folder,
CR (gp_file_set_type (file, GP_FILE_TYPE_EXIF));
CR (gp_file_set_name (file, filename));
CR (gp_file_set_mime_type (file, GP_MIME_EXIF));
- CR (gp_filesystem_set_file_noop (fs, folder, file, context));
+ CR (gp_filesystem_set_file_noop (fs, folder, filename, file, context));
CR (gp_file_adjust_name_for_mime_type (file));
#else
GP_DEBUG ("Getting EXIF data is not supported and libgphoto2 "
@@ -2039,21 +2038,20 @@ gp_filesystem_lru_count (CameraFilesystem *fs)
}
static int
-gp_filesystem_lru_update (CameraFilesystem *fs, const char *folder,
+gp_filesystem_lru_update (CameraFilesystem *fs,
+ const char *folder, const char *filename,
CameraFile *file, GPContext *context)
{
CameraFilesystemFolder *f;
CameraFilesystemFile *xfile;
CameraFileType type;
CameraFile *oldfile = NULL;
- const char *filename;
unsigned long int size;
int x;
char cached_images[1024];
CHECK_NULL (fs && folder && file);
- CR (gp_file_get_name (file, &filename));
CR (gp_file_get_type (file, &type));
CR (gp_file_get_data_and_size (file, NULL, &size));
@@ -2199,14 +2197,14 @@ gp_filesystem_lru_check (CameraFilesystem *fs)
* \return a gphoto2 error code.
**/
int
-gp_filesystem_set_file_noop (CameraFilesystem *fs, const char *folder,
+gp_filesystem_set_file_noop (CameraFilesystem *fs,
+ const char *folder, const char *filename,
CameraFile *file, GPContext *context)
{
CameraFileType type;
CameraFileInfo info;
CameraFilesystemFolder *f;
CameraFilesystemFile *xfile;
- const char *filename;
int r;
time_t t;
@@ -2214,7 +2212,6 @@ gp_filesystem_set_file_noop (CameraFilesystem *fs, const char *folder,
CC (context);
CA (folder, context);
- CR (gp_file_get_name (file, &filename));
CR (gp_file_get_type (file, &type));
GP_DEBUG ("Adding file '%s' to folder '%s' (type %i)...",
filename, folder, type);
@@ -2230,7 +2227,7 @@ gp_filesystem_set_file_noop (CameraFilesystem *fs, const char *folder,
*/
if ((type == GP_FILE_TYPE_RAW) || (type == GP_FILE_TYPE_NORMAL) ||
(type == GP_FILE_TYPE_AUDIO))
- CR (gp_filesystem_lru_update (fs, folder, file, context));
+ CR (gp_filesystem_lru_update (fs, folder, filename, file, context));
/* Redundant sanity check. */
CR (gp_filesystem_lru_check (fs));
@@ -2337,7 +2334,8 @@ gp_filesystem_set_file_noop (CameraFilesystem *fs, const char *folder,
* \return a gphoto2 error code
**/
int
-gp_filesystem_set_info_noop (CameraFilesystem *fs, const char *folder,
+gp_filesystem_set_info_noop (CameraFilesystem *fs,
+ const char *folder, const char *filename,
CameraFileInfo info, GPContext *context)
{
CameraFilesystemFolder *f;
@@ -2348,7 +2346,7 @@ gp_filesystem_set_info_noop (CameraFilesystem *fs, const char *folder,
CA (folder, context);
/* Search folder and file */
- CR (lookup_folder_file (fs, folder, info.file.name, &f, &xfile, context));
+ CR (lookup_folder_file (fs, folder, filename, &f, &xfile, context));
memcpy (&xfile->info, &info, sizeof (CameraFileInfo));
xfile->info_dirty = 0;
@@ -2372,7 +2370,7 @@ gp_filesystem_set_info (CameraFilesystem *fs, const char *folder,
const char *filename, CameraFileInfo info,
GPContext *context)
{
- int result, name, e;
+ int result;
CameraFilesystemFolder *f;
CameraFilesystemFile *xfile;
@@ -2412,11 +2410,7 @@ gp_filesystem_set_info (CameraFilesystem *fs, const char *folder,
/*
* Set the info. If anything goes wrong, mark info as dirty,
* because the operation could have been partially successful.
- *
- * Handle name changes in a separate round.
*/
- name = (info.file.fields & GP_FILE_INFO_NAME);
- info.file.fields &= ~GP_FILE_INFO_NAME;
result = fs->set_info_func (fs, folder, filename, info, fs->info_data,
context);
if (result < 0) {
@@ -2426,28 +2420,6 @@ gp_filesystem_set_info (CameraFilesystem *fs, const char *folder,
if (info.file.fields & GP_FILE_INFO_PERMISSIONS)
xfile->info.file.permissions = info.file.permissions;
- /* Handle name change */
- if (name) {
- char *xname;
- /* Make sure the file does not exist */
- e = gp_filesystem_number (fs, folder, info.file.name, context);
- if (e != GP_ERROR_FILE_NOT_FOUND)
- return (e);
-
- info.preview.fields = GP_FILE_INFO_NONE;
- info.file.fields = GP_FILE_INFO_NAME;
- info.audio.fields = GP_FILE_INFO_NONE;
- CR (fs->set_info_func (fs, folder, filename, info,
- fs->info_data, context));
- strncpy (xfile->info.file.name, info.file.name,
- sizeof (xfile->info.file.name));
- xname = strdup(info.file.name);
- if (xname) {
- free (xfile->name);
- xfile->name = xname;
- }
- }
-
return (GP_OK);
}