summaryrefslogtreecommitdiff
path: root/src/FileUtils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/FileUtils.c')
-rw-r--r--src/FileUtils.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/FileUtils.c b/src/FileUtils.c
new file mode 100644
index 0000000..3cf2997
--- /dev/null
+++ b/src/FileUtils.c
@@ -0,0 +1,18 @@
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+int minici_fd_open_read( const char * from )
+{
+ return open( from, O_RDONLY | O_CLOEXEC );
+}
+
+int minici_fd_create_write( const char * from, int fd_perms )
+{
+ struct stat st;
+ mode_t mode = 0600;
+ if( fstat( fd_perms, & st ) == 0 )
+ mode = st.st_mode;
+
+ return open( from, O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, mode );
+}