simple api to change dir

master
Daniel Kolesa 2015-09-14 01:31:31 +01:00
parent f78aac9040
commit 0c26f0c94e
1 changed files with 13 additions and 0 deletions

View File

@ -537,6 +537,19 @@ inline FileInfo path_join(const A &...args) {
return FileInfo(path);
}
inline bool directory_change(ConstCharRange path) {
char buf[1024];
if (path.size() >= 1024)
return false;
memcpy(buf, path.data(), path.size());
buf[path.size()] = '\0';
#ifndef OSTD_PLATFORM_WIN32
return !chdir(buf);
#else
return !_chdir(buf);
#endif
}
} /* namespace ostd */
#endif