]> www.fi.muni.cz Git - evince.git/blob - pdf/goo/gfile.h
drag and drop, removed redundant verb popup code.
[evince.git] / pdf / goo / gfile.h
1 //========================================================================
2 //
3 // gfile.h
4 //
5 // Miscellaneous file and directory name manipulation.
6 //
7 // Copyright 1996 Derek B. Noonburg
8 //
9 //========================================================================
10
11 #ifndef GFILE_H
12 #define GFILE_H
13
14 #include <stdlib.h>
15 #include <stddef.h>
16 #ifdef WIN32
17 #  include <kpathsea/win32lib.h>
18 #else
19 #  include <unistd.h>
20 #  include <sys/types.h>
21 #  ifdef VMS
22 #    include "vms_dirent.h"
23 #  elif HAVE_DIRENT_H
24 #    include <dirent.h>
25 #    define NAMLEN(dirent) strlen((dirent)->d_name)
26 #  else
27 #    define dirent direct
28 #    define NAMLEN(dirent) (dirent)->d_namlen
29 #    if HAVE_SYS_NDIR_H
30 #      include <sys/ndir.h>
31 #    endif
32 #    if HAVE_SYS_DIR_H
33 #      include <sys/dir.h>
34 #    endif
35 #    if HAVE_NDIR_H
36 #      include <ndir.h>
37 #    endif
38 #  endif
39 #endif
40 #include "gtypes.h"
41
42 class GString;
43
44 //------------------------------------------------------------------------
45
46 // Get home directory path.
47 extern GString *getHomeDir();
48
49 // Get current directory.
50 extern GString *getCurrentDir();
51
52 // Append a file name to a path string.  <path> may be an empty
53 // string, denoting the current directory).  Returns <path>.
54 extern GString *appendToPath(GString *path, char *fileName);
55
56 // Grab the path from the front of the file name.  If there is no
57 // directory component in <fileName>, returns an empty string.
58 extern GString *grabPath(char *fileName);
59
60 // Is this an absolute path or file name?
61 extern GBool isAbsolutePath(char *path);
62
63 // Make this path absolute by prepending current directory (if path is
64 // relative) or prepending user's directory (if path starts with '~').
65 GString *makePathAbsolute(GString *path);
66
67 //------------------------------------------------------------------------
68 // GDir and GDirEntry
69 //------------------------------------------------------------------------
70
71 class GDirEntry {
72 public:
73
74   GDirEntry(char *dirPath, char *name1, GBool doStat);
75   ~GDirEntry();
76   GString *getName() { return name; }
77   GBool isDir() { return dir; }
78
79 private:
80
81   GString *name;                // dir/file name
82   GBool dir;                    // is it a directory?
83 };
84
85 class GDir {
86 public:
87
88   GDir(char *name, GBool doStat1 = gTrue);
89   ~GDir();
90   GDirEntry *getNextEntry();
91   void rewind();
92
93 private:
94
95   GString *path;                // directory path
96   GBool doStat;                 // call stat() for each entry?
97 #ifdef VMS
98   GBool needParent;             // need to return an entry for [-]
99 #endif
100 #ifdef WIN32
101   WIN32_FIND_DATA ffd;
102   HANDLE hnd;
103 #else
104   DIR *dir;                     // the DIR structure from opendir()
105 #endif
106 };
107
108 #endif