* Changes current working directory to /tmp and creates ~/.dillo * if not exists. */
| 29 | * if not exists. |
| 30 | */ |
| 31 | void 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. |
nothing calls this directly
no test coverage detected