summaryrefslogtreecommitdiff
path: root/tests/test-filesys.c
diff options
context:
space:
mode:
authorLutz Mueller <lutz@users.sourceforge.net>2001-08-27 11:04:29 +0000
committerLutz Mueller <lutz@users.sourceforge.net>2001-08-27 11:04:29 +0000
commitf5fd86d5e33d771b5743065b6979d2d4214990ee (patch)
treee6cdaa766a6e231faf077867bb7d6f525b9cb056 /tests/test-filesys.c
parentf4de8d0b9d1633ca3cc987cc890aa4453f47c33b (diff)
downloadlibgphoto2-f5fd86d5e33d771b5743065b6979d2d4214990ee.tar.gz
2001-08-27 Lutz M�ller <urc8@rz.uni-karlsruhe.de>
* include/gphoto2-filesys.h: * libgphoto2/filesys.c: Implement caching for file information. * tests/test-filesys.c: Test it here. * camlibs/konica/library.c: Use gp_filesystem_[get,set]_info. This stuff is really incredibly fast. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2090 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'tests/test-filesys.c')
-rw-r--r--tests/test-filesys.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test-filesys.c b/tests/test-filesys.c
index bc739e4b7..02e72fd92 100644
--- a/tests/test-filesys.c
+++ b/tests/test-filesys.c
@@ -6,16 +6,43 @@
#define CHECK(r) {int ret = r; if (ret != GP_OK) {printf ("Got error: %s\n", gp_result_as_string (ret)); return (1);}}
+static int
+set_info_func (CameraFilesystem *fs, const char *folder, const char *file,
+ CameraFileInfo *info, void *data)
+{
+ printf (" -> The camera will set the file info here.\n");
+
+ return (GP_OK);
+}
+
+static int
+get_info_func (CameraFilesystem *fs, const char *folder, const char *file,
+ CameraFileInfo *info, void *data)
+{
+ printf (" -> The camera will get the file info here.\n");
+
+ info->preview.fields = GP_FILE_INFO_NONE;
+ info->file.fields = GP_FILE_INFO_NAME;
+ strcpy (info->file.name, "Some file on the camera");
+
+ return (GP_OK);
+}
+
int
main (int argc, char **argv)
{
CameraFilesystem *fs;
+ CameraFileInfo info;
CHECK (gp_init (GP_DEBUG_HIGH));
printf ("*** Creating file system...\n");
CHECK (gp_filesystem_new (&fs));
+ printf ("*** Setting the info callbacks...\n");
+ CHECK (gp_filesystem_set_info_funcs (fs, get_info_func, set_info_func,
+ NULL));
+
printf ("*** Adding a file...\n");
CHECK (gp_filesystem_append (fs, "/", "my.file"));
@@ -58,6 +85,22 @@ main (int argc, char **argv)
gp_filesystem_dump (fs);
+ printf ("*** Getting info about a file...\n");
+ CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file",
+ &info));
+
+ printf ("*** Getting info again (cache!)...\n");
+ CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file",
+ &info));
+
+ printf ("*** Set info about another file...\n");
+ CHECK (gp_filesystem_set_info (fs, "/whatever/directory", "some.file2",
+ &info));
+
+ printf ("*** Getting info about this file (cache!)...\n");
+ CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file2",
+ &info));
+
printf ("*** Deleting a file...\n");
CHECK (gp_filesystem_delete (fs, "/whatever/directory", "some.file2"));