summaryrefslogtreecommitdiff
path: root/src/FileUtils.c
blob: 3cf2997c3d07f2b135a6cd0b6b8989b7d7f139f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 );
}