From f634f7672839f89b8b62f564827e7d7fa5b24b6d Mon Sep 17 00:00:00 2001 From: Nathan Clack Date: Thu, 7 Sep 2023 07:07:11 -0700 Subject: [PATCH] Fix win file permissions (#29) It was found during testing that I could configure each video stream to write to the same tiff file and everything proceeded just fine. Both streams happily overwrote each other's data in the one created file. That shouldn't happen. This PR fixes the access flag, but doesn't add a test. This should be a windows specific problem. --------- Co-authored-by: Alan Liddell --- src/acquire-core-platform/linux/platform.c | 2 +- src/acquire-core-platform/osx/platform.c | 2 +- src/acquire-core-platform/win32/platform.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/acquire-core-platform/linux/platform.c b/src/acquire-core-platform/linux/platform.c index be48149..eb0f855 100644 --- a/src/acquire-core-platform/linux/platform.c +++ b/src/acquire-core-platform/linux/platform.c @@ -36,7 +36,7 @@ int file_create(struct file* file, const char* filename, size_t bytesof_filename) { - file->fid = open(filename, O_RDWR | O_CREAT | O_NONBLOCK, 0666); + file->fid = open(filename, O_RDWR | O_CREAT | O_EXCL | O_NONBLOCK, 0666); if (file->fid < 0) CHECK_POSIX(errno); return 1; diff --git a/src/acquire-core-platform/osx/platform.c b/src/acquire-core-platform/osx/platform.c index 881f466..bf94fbd 100644 --- a/src/acquire-core-platform/osx/platform.c +++ b/src/acquire-core-platform/osx/platform.c @@ -44,7 +44,7 @@ int file_create(struct file* file, const char* filename, size_t bytesof_filename) { - file->fid = open(filename, O_RDWR | O_CREAT | O_NONBLOCK, 0666); + file->fid = open(filename, O_RDWR | O_CREAT | O_EXCL | O_NONBLOCK, 0666); if (file->fid < 0) CHECK_POSIX(errno); return 1; diff --git a/src/acquire-core-platform/win32/platform.c b/src/acquire-core-platform/win32/platform.c index 8c20662..4d77ed9 100644 --- a/src/acquire-core-platform/win32/platform.c +++ b/src/acquire-core-platform/win32/platform.c @@ -74,7 +74,7 @@ file_create(struct file* file, const char* filename, size_t bytes_of_filename) CHECK_HANDLE(file->hfile = CreateFileA(filename, GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_FLAG_OVERLAPPED,