2 * Filesystem utility definitions
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 * Get the pathname of the directory from which the executable came,
30 * and save it for future use. Returns NULL on success, and a
31 * g_mallocated string containing an error on failure.
33 extern char *init_progfile_dir(const char *arg0);
36 * Get the directory in which the program resides.
38 extern const char *get_progfile_dir(void);
41 * Get the directory in which plugins are stored; this must not be called
42 * before init_progfile_dir() is called, as they might be stored in a
43 * subdirectory of the program file directory.
45 extern const char *get_plugin_dir(void);
48 * Get the flag indicating whether we're running from a build
51 extern gboolean running_in_build_directory(void);
54 * Get the directory in which global configuration files are
57 extern const char *get_datafile_dir(void);
60 * Construct the path name of a global configuration file, given the
63 extern char *get_datafile_path(const char *filename);
66 * Get the directory in which files that, at least on UNIX, are
67 * system files (such as "/etc/ethers") are stored; on Windows,
68 * there's no "/etc" directory, so we get them from the Wireshark
69 * global configuration and data file directory.
71 extern const char *get_systemfile_dir(void);
74 * Create the directory that holds personal configuration files, if
75 * necessary. If we attempted to create it, and failed, return -1 and
76 * set "*pf_dir_path_return" to the pathname of the directory we failed
77 * to create (it's g_mallocated, so our caller should free it); otherwise,
80 extern int create_persconffile_dir(char **pf_dir_path_return);
83 * Construct the path name of a personal configuration file, given the
86 * On Win32, if "for_writing" is FALSE, we check whether the file exists
87 * and, if not, construct a path name relative to the ".wireshark"
88 * subdirectory of the user's home directory, and check whether that
89 * exists; if it does, we return that, so that configuration files
90 * from earlier versions can be read.
92 extern char *get_persconffile_path(const char *filename, gboolean for_writing);
95 * Get the (default) directory in which personal data is stored.
97 * On Win32, this is the "My Documents" folder in the personal profile.
98 * On UNIX this is simply the current directory.
100 extern char *get_persdatafile_dir(void);
103 * Construct the path name of a file in $TMP/%TEMP% directory.
104 * Or "/tmp/<filename>" (C:\<filename>) if that fails.
106 * Return value is malloced so the caller should free it.
108 extern char *get_tempfile_path(const char *filename);
111 * process command line option belonging to the filesystem settings
113 extern int filesystem_opt(int opt, const char *optarg);
116 * Return an error message for UNIX-style errno indications on open or
119 extern const char *file_open_error_message(int err, gboolean for_writing);
122 * Return an error message for UNIX-style errno indications on write
125 extern const char *file_write_error_message(int err);
128 * Given a pathname, return the last component.
130 extern const char *get_basename(const char *);
133 * Given a pathname, return a string containing everything but the
134 * last component. NOTE: this overwrites the pathname handed into
137 extern char *get_dirname(char *);
140 * Given a pathname, return:
142 * the errno, if an attempt to "stat()" the file fails;
144 * EISDIR, if the attempt succeeded and the file turned out
147 * 0, if the attempt succeeded and the file turned out not
150 extern int test_for_directory(const char *);
153 * Given a pathname, return:
155 * the errno, if an attempt to "stat()" the file fails;
157 * ESPIPE, if the attempt succeeded and the file turned out
160 * 0, if the attempt succeeded and the file turned out not
163 extern int test_for_fifo(const char *);
166 extern gboolean deletefile (const char *path);
169 * Check, if file is existing.
171 extern gboolean file_exists(const char *fname);
174 * Check, if two filenames are identical (with absolute and relative paths).
176 extern gboolean files_identical(const char *fname1, const char *fname2);
180 * utf8 version of getenv, needed to get win32 filename paths
182 extern char *getenv_utf8(const char *varname);
185 #endif /* FILESYSTEM_H */