Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

19 lines (14 sloc) 597 Bytes
// Copyright (c) 2010-2013 David Caldwell <>
// Licenced under the GPL 3.0 or any later version. See LICENSE file for details.
#include <sys/stat.h>
#include <unistd.h>
#include "posix-util.h"
#include "strprintf.h"
using namespace std;
void mkdir_ug(string path, mode_t mode, int uid, int gid)
struct stat st;
if (stat(path.c_str(), &st) != 0)
mkdir(path.c_str(), mode) == -1 && throw_strerr("mkdir %s failed", path.c_str());
chown(path.c_str(), uid, gid) == -1 && throw_strerr("Couldn't change %s to uid %d gid %d", path.c_str(), uid, gid);
Jump to Line
Something went wrong with that request. Please try again.