File: md

package info (click to toggle)
c++-annotations 11.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 11,244 kB
  • sloc: cpp: 21,698; makefile: 1,505; ansic: 165; sh: 121; perl: 90
file content (42 lines) | stat: -rw-r--r-- 857 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// md: target should be a series of blank-delimited directories to be created
//     If an element is a whildcard, the directory will always be created,
//     using mkdir -p.
//
//     uses: run()

// if the target directory does not exist it is created and its realpath is
// logged.

string g_lastLogged;

void md(string target)
{
    int idx;
    list paths;
    string dir;

    if (!exists(target))
        run("mkdir -p " + target);
    else if (((int)stat(target)[0] & S_IFDIR) == 0)
    {
        printf(target + " exists, but is not a directory\n");
        exit(1);
    }


    if (g_installing)
    {
        target = cutEoln(backtick("realpath " + target)[0]);
        if (target != g_lastLogged)
        {
            g_lastLogged = target;
            mark();
            g_log += (list)(g_logMark + " dir " + target);
        }
    }
}