Example #1
0
/// Make a directory.
///
/// @return `0` for success, non-zero for failure.
int os_mkdir(const char *path, int32_t mode)
{
  uv_fs_t request;
  int result = uv_fs_mkdir(uv_default_loop(), &request, path, mode, NULL);
  uv_fs_req_cleanup(&request);
  return result;
}
Example #2
0
static void create_dir(uv_loop_t* loop, const char* name) {
    int r;
    uv_fs_t req;
    r = uv_fs_mkdir(loop, &req, name, 0755, NULL);
    ASSERT(r == 0 || uv_last_error(loop).code == UV_EEXIST);
    uv_fs_req_cleanup(&req);
}
Example #3
0
static void create_dir(const char* name) {
  int r;
  uv_fs_t req;
  r = uv_fs_mkdir(NULL, &req, name, 0755, NULL);
  ASSERT(r == 0 || r == UV_EEXIST);
  uv_fs_req_cleanup(&req);
}
Example #4
0
static void create_dir(uv_loop_t* loop, const char* name) {
  int r;
  uv_fs_t req;
  r = uv_fs_rmdir(loop, &req, name, NULL);
  r = uv_fs_mkdir(loop, &req, name, 0755, NULL);
  ASSERT(r == 0);
  uv_fs_req_cleanup(&req);
}
Example #5
0
/*
 * fs.mkdir
 */
static int fs_mkdir(lua_State* L) {
  FSR__SETUP
  const char *path = luaL_checkstring(L, 1);
  const char *mode_str = luaL_optstring(L, 2, "0777");
  int mode = strtol(mode_str, (char**) NULL, 8);
  FSR__SET_OPT_CB(3, on_fs_callback)
  uv_fs_mkdir(loop, req, path, mode, cb);
  FSR__TEARDOWN
}
Example #6
0
void ensure_directory_exists_for_file(const std::string &file_path)
{
    size_t pos = 0;

    while ((pos = file_path.find_first_of('/', pos)) != std::string::npos) {
        // Skip for leading slash.
        if (pos == 0) {
            pos++;
            continue;
        }

        std::string dir_path = file_path.substr(0, pos++);
        FileSystemRequest req;
        if (uv_fs_mkdir(uv_default_loop(), &req, dir_path.c_str(), 0755, nullptr) < 0 && req.result != UV_EEXIST) {
            throw UVException(static_cast<uv_errno_t>(req.result));
        }
    }
}
Example #7
0
void makeDir(char * dir)
{
	uv_fs_t mkdir_req;
	uv_fs_mkdir(uv_default_loop(), &mkdir_req, dir, 0700, NULL);
	uv_fs_req_cleanup(&mkdir_req);
}
Example #8
0
extern "C" int
rust_uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb) {
  return uv_fs_mkdir(loop, req, path, mode, cb);
}