File: abssource

package info (click to toggle)
icmake 13.05.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,132 kB
  • sloc: cpp: 11,595; fortran: 883; makefile: 853; sh: 546; pascal: 342
file content (21 lines) | stat: -rw-r--r-- 914 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
    // source entries must exist as files or directories
    // If they start with ~/ then they are under the HOME dir. 
    // if they start with / then they're absolute
    // otherwise they are in the skeleton path(by default g_skelPath)
    //
    // plain source (e.g., CLASSES)         -> g_skelPath + CLASSES
    // relative to home (e.g., ~/path/file) -> ${HOME}/path/file
    // absolute: /path1/path2               -> /path1/path2
    //
string absSource(string source)
{
    if (strfind(source, "~/") == 0) // relative to home
        source = readlink(source);  // readlink solves the ~/
    else if (source[0] != '/')      // not absolute, then rel. to skelPath
        source = g_skelPath + source;   

    if (!isFileOrDir(source))       // and it must exist (either dir or file)
        quit("Can't find source `" + source + "'");

    return source;                  // return the absolute path
}