add open to utils

This commit is contained in:
2021-12-16 13:47:46 +08:00
parent 6e0f72d7ed
commit 751373e0e4
4 changed files with 57 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
#include "cfileop.h"
#include "fileop.h"
#include "cpp2c.h"
#include <errno.h>
int fileop_exists(const char* fn) {
if (!fn) return 0;
@@ -39,3 +40,12 @@ int fileop_parse_size(const char* size, size_t* fs, int is_byte) {
if (re) *fs = tmp;
return re ? 1 : 0;
}
int fileop_open(const char* fn, int* fd, int oflag, int shflag, int pmode) {
if (!fn || !fd) return EINVAL;
int tfd;
if (!shflag) shflag = 0x10;
int re = fileop::open(fn, tfd, oflag, shflag, pmode);
*fd = tfd;
return re;
}