diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/best-iso.c | 9 | ||||
-rw-r--r-- | examples/lunkwill-canon-capture.c | 2 | ||||
-rw-r--r-- | examples/preview.c | 2 | ||||
-rw-r--r-- | examples/sample-capture.c | 2 | ||||
-rw-r--r-- | examples/sample-photobooth.c | 4 | ||||
-rw-r--r-- | examples/sample-tether.c | 2 | ||||
-rw-r--r-- | examples/sample-trigger-capture.c | 2 | ||||
-rw-r--r-- | examples/samples.h | 6 |
8 files changed, 20 insertions, 9 deletions
diff --git a/examples/best-iso.c b/examples/best-iso.c index e46220672..84204b3f9 100644 --- a/examples/best-iso.c +++ b/examples/best-iso.c @@ -14,6 +14,11 @@ #include <string.h> #include <gphoto2/gphoto2.h> +#if !defined (O_BINARY) + /*To have portable binary open() on *nix and on Windows */ + #define O_BINARY 0 +#endif + #define DEBUG static int aperture; @@ -229,7 +234,7 @@ camera_tether(Camera *camera, GPContext *context) { path = (CameraFilePath*)evtdata; printf("File added on the camera: %s/%s\n", path->folder, path->name); - fd = open(path->name, O_CREAT | O_WRONLY, 0644); + fd = open(path->name, O_CREAT | O_WRONLY | O_BINARY, 0644); retval = gp_file_new_from_fd(&file, fd); printf(" Downloading %s...\n", path->name); retval = gp_camera_file_get(camera, path->folder, path->name, @@ -400,7 +405,7 @@ main(int argc, char **argv) { printf("Pathname on the camera: %s/%s\n", camera_file_path.folder, camera_file_path.name); - fd = open("capture.jpg", O_CREAT | O_WRONLY, 0644); + fd = open("capture.jpg", O_CREAT | O_WRONLY | O_BINARY, 0644); retval = gp_file_new_from_fd(&file, fd); if (retval != GP_OK) printf(" gp_file_new failed: %d\n", retval); diff --git a/examples/lunkwill-canon-capture.c b/examples/lunkwill-canon-capture.c index 630c2918c..f7f4280e6 100644 --- a/examples/lunkwill-canon-capture.c +++ b/examples/lunkwill-canon-capture.c @@ -107,7 +107,7 @@ capture_to_file(Camera *canon, GPContext *canoncontext, char *fn) { printf("Pathname on the camera: %s/%s\n", camera_file_path.folder, camera_file_path.name); - fd = open(fn, O_CREAT | O_WRONLY, 0644); + fd = open(fn, O_CREAT | O_WRONLY | O_BINARY, 0644); retval = gp_file_new_from_fd(&canonfile, fd); printf(" Retval: %d\n", retval); retval = gp_camera_file_get(canon, camera_file_path.folder, camera_file_path.name, diff --git a/examples/preview.c b/examples/preview.c index 4157cf0d6..162e59664 100644 --- a/examples/preview.c +++ b/examples/preview.c @@ -100,7 +100,7 @@ capture_to_file(Camera *canon, GPContext *canoncontext, char *fn) { printf("Pathname on the camera: %s/%s\n", camera_file_path.folder, camera_file_path.name); - fd = open(fn, O_CREAT | O_WRONLY, 0644); + fd = open(fn, O_CREAT | O_WRONLY | O_BINARY, 0644); retval = gp_file_new_from_fd(&canonfile, fd); printf(" Retval: %d\n", retval); retval = gp_camera_file_get(canon, camera_file_path.folder, camera_file_path.name, diff --git a/examples/sample-capture.c b/examples/sample-capture.c index 952b434c7..a3a932871 100644 --- a/examples/sample-capture.c +++ b/examples/sample-capture.c @@ -77,7 +77,7 @@ capture_to_file(Camera *camera, GPContext *context, char *fn) { printf("Pathname on the camera: %s/%s\n", camera_file_path.folder, camera_file_path.name); - fd = open(fn, O_CREAT | O_WRONLY, 0644); + fd = open(fn, O_CREAT | O_WRONLY | O_BINARY, 0644); retval = gp_file_new_from_fd(&file, fd); printf(" Retval: %d\n", retval); retval = gp_camera_file_get(camera, camera_file_path.folder, camera_file_path.name, diff --git a/examples/sample-photobooth.c b/examples/sample-photobooth.c index 65327152e..180e4e366 100644 --- a/examples/sample-photobooth.c +++ b/examples/sample-photobooth.c @@ -43,7 +43,7 @@ capture_to_file(Camera *camera, GPContext *context, char *fn) { strcpy (s+1, t+1); } - fd = open(fn, O_CREAT | O_WRONLY, 0644); + fd = open (fn, O_CREAT | O_WRONLY | O_BINARY, 0644); if (fd == -1) return GP_ERROR; @@ -205,7 +205,7 @@ main(int argc, char **argv) { sprintf(output_file, "image-%04d.jpg", capturecnt++); } - fd = open(output_file, O_CREAT | O_WRONLY, 0644); + fd = open (output_file, O_CREAT | O_WRONLY | O_BINARY, 0644); retval = gp_file_new_from_fd(&file, fd); retval = gp_camera_file_get(camera, path->folder, path->name, GP_FILE_TYPE_NORMAL, file, context); diff --git a/examples/sample-tether.c b/examples/sample-tether.c index 7721ec550..3b6f863b8 100644 --- a/examples/sample-tether.c +++ b/examples/sample-tether.c @@ -41,7 +41,7 @@ camera_tether(Camera *camera, GPContext *context) { path = (CameraFilePath*)evtdata; printf("File added on the camera: %s/%s\n", path->folder, path->name); - fd = open(path->name, O_CREAT | O_WRONLY, 0644); + fd = open (path->name, O_CREAT | O_WRONLY | O_BINARY, 0644); retval = gp_file_new_from_fd(&file, fd); printf(" Downloading %s...\n", path->name); retval = gp_camera_file_get(camera, path->folder, path->name, diff --git a/examples/sample-trigger-capture.c b/examples/sample-trigger-capture.c index baa968905..aa94dd3db 100644 --- a/examples/sample-trigger-capture.c +++ b/examples/sample-trigger-capture.c @@ -101,7 +101,7 @@ wait_event_and_download (Camera *camera, int waittime, GPContext *context) { if (-1 == stat(queue[0].path.name, &stbuf)) fd = creat(queue[0].path.name, 0644); else - fd = open(queue[0].path.name, O_RDWR, 0644); + fd = open(queue[0].path.name, O_RDWR | O_BINARY, 0644); if (fd == -1) { perror(queue[0].path.name); return GP_ERROR; diff --git a/examples/samples.h b/examples/samples.h index 9132c6cb3..b7c0197a9 100644 --- a/examples/samples.h +++ b/examples/samples.h @@ -13,4 +13,10 @@ int canon_enable_capture (Camera *camera, int onoff, GPContext *context); extern int camera_auto_focus (Camera *list, GPContext *context, int onoff); extern int camera_eosviewfinder (Camera *list, GPContext *context, int onoff); extern int camera_manual_focus (Camera *list, int tgt, GPContext *context); + +#if !defined (O_BINARY) + /*To have portable binary open() on *nix and on Windows */ + #define O_BINARY 0 +#endif + #endif |