gphoto4ruby 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +4 -0
- data/README.rdoc +1 -1
- data/ext/gphoto4ruby.c +28 -13
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -36,7 +36,7 @@ calling object methods.
|
|
36
36
|
|
37
37
|
ruby example.rb
|
38
38
|
|
39
|
-
* <b>NOTE
|
39
|
+
* <b>NOTE!</b> On Mac OS X there is a process you need to kill before using
|
40
40
|
gphoto2. You can find more information on this at http://gphoto.org
|
41
41
|
|
42
42
|
== Usage
|
data/ext/gphoto4ruby.c
CHANGED
@@ -309,7 +309,9 @@ static VALUE camera_capture(int argc, VALUE *argv, VALUE self) {
|
|
309
309
|
* Available options are:
|
310
310
|
* * :file - Name of the file to download from camera. File is expected
|
311
311
|
* to be found in current path. If this option is not specified, last
|
312
|
-
* captured image is downloaded.
|
312
|
+
* captured image is downloaded. If symbols <b>:first</b> or <b>:last</b>
|
313
|
+
* are passed, the first or the last file from current camera path is
|
314
|
+
* downloaded.
|
313
315
|
* * :new_name - New file name to be used when saving file on hard drive.
|
314
316
|
* If this option is not specified, camera file system filename is used.
|
315
317
|
* * :to_folder - Folder path on hard drive to save downloaded image to.
|
@@ -327,11 +329,11 @@ static VALUE camera_capture(int argc, VALUE *argv, VALUE self) {
|
|
327
329
|
*
|
328
330
|
*/
|
329
331
|
static VALUE camera_save(int argc, VALUE *argv, VALUE self) {
|
330
|
-
int i;
|
332
|
+
int i, count;
|
331
333
|
int newName = -1;
|
332
334
|
CameraFileType fileType = GP_FILE_TYPE_NORMAL;
|
333
335
|
GPhoto2Camera *c;
|
334
|
-
const char *fData, *key, *val;
|
336
|
+
const char *fData, *key, *val, *name;
|
335
337
|
char *fPath, *newNameStr, *pchNew, *pchSrc;
|
336
338
|
char fName[100], cFileName[100], cFolderName[100];
|
337
339
|
unsigned long int fSize;
|
@@ -344,6 +346,8 @@ static VALUE camera_save(int argc, VALUE *argv, VALUE self) {
|
|
344
346
|
strcpy(cFileName, c->path.name);
|
345
347
|
strcpy(cFolderName, c->path.folder);
|
346
348
|
|
349
|
+
gp_result_check(gp_filesystem_reset(c->camera->fs));
|
350
|
+
|
347
351
|
switch(argc) {
|
348
352
|
case 0:
|
349
353
|
break;
|
@@ -378,26 +382,38 @@ static VALUE camera_save(int argc, VALUE *argv, VALUE self) {
|
|
378
382
|
newName = 0;
|
379
383
|
}
|
380
384
|
} else if (strcmp(key, "type") == 0) {
|
385
|
+
hVal = rb_hash_aref(argv[0], RARRAY(arr)->ptr[i]);
|
386
|
+
Check_Type(hVal, T_SYMBOL);
|
387
|
+
val = rb_id2name(rb_to_id(hVal));
|
388
|
+
if (strcmp(val, "normal") == 0) {
|
389
|
+
fileType = GP_FILE_TYPE_NORMAL;
|
390
|
+
} else if (strcmp(val, "preview") == 0) {
|
391
|
+
fileType = GP_FILE_TYPE_PREVIEW;
|
392
|
+
}
|
393
|
+
} else if (strcmp(key, "file") == 0) {
|
381
394
|
hVal = rb_hash_aref(argv[0], RARRAY(arr)->ptr[i]);
|
382
395
|
switch(TYPE(hVal)) {
|
383
396
|
case T_STRING:
|
384
|
-
|
397
|
+
strcpy(cFolderName, c->virtFolder);
|
398
|
+
strcpy(cFileName, RSTRING(hVal)->ptr);
|
385
399
|
break;
|
386
400
|
case T_SYMBOL:
|
387
401
|
val = rb_id2name(rb_to_id(hVal));
|
402
|
+
gp_result_check(gp_camera_folder_list_files(c->camera, c->virtFolder, c->list, c->context));
|
403
|
+
if (strcmp(val, "first") == 0) {
|
404
|
+
count = 0;
|
405
|
+
} else if (strcmp(val, "last") == 0) {
|
406
|
+
count = gp_result_check(gp_list_count(c->list)) - 1;
|
407
|
+
} else {
|
408
|
+
count = -1;
|
409
|
+
}
|
410
|
+
gp_result_check(gp_list_get_name(c->list, count, &name));
|
411
|
+
strcpy(cFileName, name);
|
388
412
|
break;
|
389
413
|
default:
|
390
414
|
rb_raise(rb_eTypeError, "Not valid value type");
|
391
415
|
return Qnil;
|
392
416
|
}
|
393
|
-
if (strcmp(val, "normal") == 0) {
|
394
|
-
fileType = GP_FILE_TYPE_NORMAL;
|
395
|
-
} else if (strcmp(val, "preview") == 0) {
|
396
|
-
fileType = GP_FILE_TYPE_PREVIEW;
|
397
|
-
}
|
398
|
-
} else if (strcmp(key, "file") == 0) {
|
399
|
-
strcpy(cFolderName, c->virtFolder);
|
400
|
-
strcpy(cFileName, RSTRING(rb_hash_aref(argv[0], RARRAY(arr)->ptr[i]))->ptr);
|
401
417
|
}
|
402
418
|
}
|
403
419
|
break;
|
@@ -406,7 +422,6 @@ static VALUE camera_save(int argc, VALUE *argv, VALUE self) {
|
|
406
422
|
return Qnil;
|
407
423
|
}
|
408
424
|
|
409
|
-
gp_result_check(gp_filesystem_reset(c->camera->fs));
|
410
425
|
gp_result_check(gp_camera_file_get(c->camera, cFolderName, cFileName, fileType, c->file, c->context));
|
411
426
|
gp_result_check(gp_file_get_data_and_size(c->file, &fData, &fSize));
|
412
427
|
if (newName == 0) {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gphoto4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- heq4 company
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-08-
|
13
|
+
date: 2008-08-28 00:00:00 +04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|