MCPcopy Create free account
hub / github.com/dillo-browser/dillo / init

Method init

src/paths.cc:31–59  ·  view source on GitHub ↗

* Changes current working directory to /tmp and creates ~/.dillo * if not exists. */

Source from the content-addressed store, hash-verified

29 * if not exists.
30 */
31void Paths::init(void)
32{
33 char *path;
34 struct stat st;
35 int rc = 0;
36
37 dFree(oldWorkingDir);
38 oldWorkingDir = dGetcwd();
39 rc = chdir("/tmp");
40 if (rc == -1) {
41 MSG("paths: Error changing directory to /tmp: %s\n",
42 dStrerror(errno));
43 }
44
45 path = dStrconcat(dGethomedir(), "/.dillo", NULL);
46 if (stat(path, &st) == -1) {
47 if (errno == ENOENT) {
48 MSG("paths: Creating directory '%s/'\n", path);
49 if (mkdir(path, 0700) < 0) {
50 MSG("paths: Error creating directory %s: %s\n",
51 path, dStrerror(errno));
52 }
53 } else {
54 MSG("Dillo: error reading %s: %s\n", path, dStrerror(errno));
55 }
56 }
57
58 dFree(path);
59}
60
61/**
62 * Return the initial current working directory in a string.

Callers

nothing calls this directly

Calls 5

dFreeFunction · 0.85
dGetcwdFunction · 0.85
dStrconcatFunction · 0.85
dGethomedirFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected