Add queue functions to NAMESPACE
[filehash.git] / src / lockfile.c
blob0420339fb492b0d249d80248213ce8284d5d9ea9
1 #include <R.h>
2 #include <Rinternals.h>
3 #include <fcntl.h>
4 #include <unistd.h>
6 SEXP lock_file(SEXP filename)
8 int fd;
9 SEXP status;
11 if(!isString(filename))
12 error("'filename' should be character");
13 PROTECT(status = allocVector(INTSXP, 1));
15 fd = open(CHAR(STRING_ELT(filename, 0)),
16 O_WRONLY | O_CREAT | O_EXCL, 0666);
17 INTEGER(status)[0] = fd;
18 close(fd);
19 UNPROTECT(1);
20 return status;