2000-09-28 03:16:29 +00:00
|
|
|
/* filesystem.h
|
|
|
|
* Filesystem utility definitions
|
|
|
|
*
|
2004-01-24 02:01:44 +00:00
|
|
|
* $Id: filesystem.h,v 1.17 2004/01/24 02:01:43 guy Exp $
|
2000-09-28 03:16:29 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
2000-09-28 03:16:29 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2000-09-28 03:16:29 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2000-09-28 03:16:29 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2000-09-28 03:16:29 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FILESYSTEM_H
|
|
|
|
#define FILESYSTEM_H
|
|
|
|
|
2001-04-02 09:53:46 +00:00
|
|
|
/*
|
|
|
|
* Given a pathname, return a pointer to the last pathname separator
|
|
|
|
* character in the pathname, or NULL if the pathname contains no
|
|
|
|
* separators.
|
|
|
|
*/
|
|
|
|
char *find_last_pathname_separator(char *);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a pathname, return the last component.
|
|
|
|
*/
|
|
|
|
char *get_basename(char *);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a pathname, return a string containing everything but the
|
|
|
|
* last component. NOTE: this overwrites the pathname handed into
|
|
|
|
* it....
|
|
|
|
*/
|
|
|
|
char *get_dirname(char *);
|
|
|
|
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
/*
|
|
|
|
* Given a pathname, return:
|
|
|
|
*
|
|
|
|
* the errno, if an attempt to "stat()" the file fails;
|
|
|
|
*
|
|
|
|
* EISDIR, if the attempt succeeded and the file turned out
|
|
|
|
* to be a directory;
|
|
|
|
*
|
|
|
|
* 0, if the attempt succeeded and the file turned out not
|
|
|
|
* to be a directory.
|
|
|
|
*/
|
|
|
|
int test_for_directory(const char *);
|
|
|
|
|
2002-06-23 21:33:09 +00:00
|
|
|
/*
|
|
|
|
* Given a pathname, return:
|
|
|
|
*
|
|
|
|
* the errno, if an attempt to "stat()" the file fails;
|
|
|
|
*
|
|
|
|
* ESPIPE, if the attempt succeeded and the file turned out
|
|
|
|
* to be a FIFO;
|
|
|
|
*
|
|
|
|
* 0, if the attempt succeeded and the file turned out not
|
|
|
|
* to be a FIFO.
|
|
|
|
*/
|
|
|
|
int test_for_fifo(const char *);
|
|
|
|
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
/*
|
|
|
|
* Get the directory in which global configuration and data files are
|
|
|
|
* stored.
|
|
|
|
*/
|
|
|
|
const char *get_datafile_dir(void);
|
|
|
|
|
2003-05-15 07:44:54 +00:00
|
|
|
/*
|
|
|
|
* Construct the path name of a global configuration file, given the
|
|
|
|
* file name.
|
|
|
|
*/
|
2003-11-18 19:20:36 +00:00
|
|
|
extern char *get_datafile_path(const char *filename);
|
2003-05-15 07:44:54 +00:00
|
|
|
|
2001-10-21 21:48:00 +00:00
|
|
|
/*
|
|
|
|
* Get the directory in which files that, at least on UNIX, are
|
|
|
|
* system files (such as "/etc/ethers") are stored; on Windows,
|
|
|
|
* there's no "/etc" directory, so we get them from the Ethereal
|
|
|
|
* global configuration and data file directory.
|
|
|
|
*/
|
|
|
|
const char *get_systemfile_dir(void);
|
|
|
|
|
2001-10-23 05:01:02 +00:00
|
|
|
/*
|
|
|
|
* Create the directory that holds personal configuration files, if
|
|
|
|
* necessary. If we attempted to create it, and failed, return -1 and
|
2001-10-24 06:13:07 +00:00
|
|
|
* set "*pf_dir_path_return" to the pathname of the directory we failed
|
|
|
|
* to create (it's g_mallocated, so our caller should free it); otherwise,
|
2001-10-23 05:01:02 +00:00
|
|
|
* return 0.
|
|
|
|
*/
|
2001-10-24 06:13:07 +00:00
|
|
|
int create_persconffile_dir(char **pf_dir_path_return);
|
2001-10-23 05:01:02 +00:00
|
|
|
|
2001-10-24 07:18:39 +00:00
|
|
|
/*
|
|
|
|
* Construct the path name of a personal configuration file, given the
|
|
|
|
* file name.
|
|
|
|
*
|
|
|
|
* On Win32, if "for_writing" is FALSE, we check whether the file exists
|
|
|
|
* and, if not, construct a path name relative to the ".ethereal"
|
|
|
|
* subdirectory of the user's home directory, and check whether that
|
|
|
|
* exists; if it does, we return that, so that configuration files
|
|
|
|
* from earlier versions can be read.
|
|
|
|
*/
|
|
|
|
char *get_persconffile_path(const char *filename, gboolean for_writing);
|
|
|
|
|
2003-11-02 23:12:35 +00:00
|
|
|
/*
|
|
|
|
* Construct the path name of a file in $TMP/%TEMP% directory.
|
|
|
|
* Or "/tmp/<filename>" (C:\<filename>) if that fails.
|
|
|
|
*
|
|
|
|
* Return value is malloced so the caller should free it.
|
|
|
|
*/
|
2003-11-18 19:20:36 +00:00
|
|
|
extern char *get_tempfile_path(const char *filename);
|
2003-11-02 23:12:35 +00:00
|
|
|
|
2003-05-15 07:44:54 +00:00
|
|
|
/* Delete a file */
|
|
|
|
gboolean deletefile (const char *path);
|
2004-01-24 01:44:29 +00:00
|
|
|
|
|
|
|
/*
|
2004-01-24 02:01:44 +00:00
|
|
|
* Return an error message for UNIX-style errno indications on open or
|
|
|
|
* create operations.
|
2004-01-24 01:44:29 +00:00
|
|
|
*/
|
|
|
|
char *file_open_error_message(int err, gboolean for_writing);
|
|
|
|
|
2004-01-24 02:01:44 +00:00
|
|
|
/*
|
|
|
|
* Return an error message for UNIX-style errno indications on write
|
|
|
|
* operations.
|
|
|
|
*/
|
|
|
|
char *file_write_error_message(int err);
|
|
|
|
|
2000-12-22 22:26:19 +00:00
|
|
|
#endif /* FILESYSTEM_H */
|