File: mkdir.cc

package info (click to toggle)
stealth 1.47.4-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 780 kB
  • ctags: 190
  • sloc: cpp: 1,710; makefile: 155; sh: 62
file content (16 lines) | stat: -rw-r--r-- 501 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "util.ih"

bool Util::mkdir(string const &path)
{
    char buffer[path.length() + 1];

    buffer[path.copy(buffer, string::npos)] = 0;    // copy the path
    char const *dir = dirname(buffer);              // construct the dirname

    return
    (
        !::mkdir(dir, S_IRWXU)                      // constructing dir ok,
        ||                                          //      (only drwx------)
        errno == EEXIST                             // or dir already existed
    );
}