27 #include "precompiled.h"
50 static DIR* (*libc_opendir)(
const char*);
51 static dirent* (*libc_readdir)(DIR*);
52 static int (*libc_closedir)(DIR*);
60 libc_opendir = (DIR*(*)(
const char*))
dlsym(libc,
"opendir");
61 libc_readdir = (dirent*(*)(DIR*))
dlsym(libc,
"readdir");
62 libc_closedir = (int(*)(DIR*))
dlsym(libc,
"closedir");
63 ENSURE(libc_opendir && libc_readdir && libc_closedir);
66 #define opendir libc_opendir
67 #define readdir libc_readdir
68 #define closedir libc_closedir
79 DIR* d = opendir(
OsString(path).c_str());
91 dirent* ent = readdir(wd->
d);
100 int ret = closedir(wd->
d);
108 ENSURE(!(oflag & O_CREAT));
109 return open(
OsString(pathname).c_str(), oflag);
114 return open(
OsString(pathname).c_str(), oflag, mode);
125 return truncate(
OsString(pathname).c_str(), length);
130 return unlink(
OsString(pathname).c_str());
135 return rmdir(
OsString(path).c_str());
140 return rename(
OsString(pathnameOld).c_str(),
OsString(pathnameNew).c_str());
146 const char* resolved = realpath(
OsString(pathname).c_str(), resolvedBuf);
154 return stat(
OsString(pathname).c_str(), buf);
159 return mkdir(
OsString(path).c_str(), mode);
LIB_API int wrmdir(const OsPath &path)
WDIR * wopendir(const OsPath &path)
LIB_API int wrename(const OsPath &pathnameOld, const OsPath &pathnameNew)
LIB_API int wtruncate(const OsPath &pathname, off_t length)
int wcscpy_s(wchar_t *dst, size_t max_dst_chars, const wchar_t *src)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
LIB_API int wunlink(const OsPath &pathname)
const String & string() const
void * dlopen(const char *so_name, int flags)
LIB_API OsPath wrealpath(const OsPath &pathname)
void * dlsym(void *handle, const char *sym_name)
wdirent * wreaddir(WDIR *)
LIB_API int wmkdir(const OsPath &path, mode_t mode)
int wopen(const OsPath &pathname, int oflag)
LIB_API int wstat(const OsPath &pathname, struct stat *buf)
static std::string OsString(const OsPath &path)