annotate src/dir.c @ 0:6ee11bf9e3ea

Initial revision
author jcid
date Sun, 07 Oct 2007 00:36:34 +0200
parents
children d9e7b35430de
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 * File: dir.c
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
4 * Copyright 2006 Jorge Arellano Cid <jcid@dillo.org>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8 * the Free Software Foundation; either version 3 of the License, or
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 * (at your option) any later version.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 #include <unistd.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14 #include "../dlib/dlib.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
16
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
17 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
18 * Local data
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
19 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
20 /* Dillo works from an unmounted directory (/tmp). */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
21 static char *OldWorkingDirectory = NULL;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
22
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
23 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
24 * Change current working directory to "/tmp".
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
26 void a_Dir_init(void)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 dFree(OldWorkingDirectory);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29 OldWorkingDirectory = dGetcwd();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30 chdir("/tmp");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
31 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34 * Return the initial current working directory in a string.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 char *a_Dir_get_owd(void)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38 return OldWorkingDirectory;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42 * Free memory
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
43 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
44 void a_Dir_free(void)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
45 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
46 dFree(OldWorkingDirectory);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
47 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
48