Gromacs
2016.6
|
Low-level wrappers for OS-specific file handling with some GROMACS customizations.
Macros | |
#define | GMX_PATH_MAX 4096 |
Maximum path length, if the OS provides one, otherwise a fixed constant. | |
Typedefs | |
typedef gmx_int64_t | gmx_off_t |
GROMACS definition to use instead of off_t . More... | |
Functions | |
void | gmx_disable_file_buffering (void) |
Turn off buffering for output files (which is default) for debugging purposes. More... | |
void | gmx_set_max_backup_count (int count) |
Enables backups with the specified number of maximum backups. More... | |
gmx_bool | gmx_fexist (const char *fname) |
Check whether a path exists. More... | |
void | make_backup (const char *file) |
Makes a backup of file if the file exists. | |
FILE * | gmx_ffopen (const char *file, const char *mode) |
Opens a file, with GROMACS-specific additions. More... | |
int | gmx_ffclose (FILE *fp) |
Closes a file opened with gmx_ffopen(). More... | |
void | frewind (FILE *fp) |
Wraps rewind() for files opened with gmx_ffopen(). More... | |
int | gmx_fseek (FILE *stream, gmx_off_t offset, int whence) |
OS-independent 64-bit fseek(). More... | |
gmx_off_t | gmx_ftell (FILE *stream) |
OS-independent 64-bit ftell(). More... | |
int | gmx_truncate (const char *filename, gmx_off_t length) |
OS-independent truncate(). More... | |
char * | gmxlibfn (const char *file) |
Finds full path for a library file. More... | |
FILE * | libopen (const char *file) |
Opens a library file for reading. More... | |
char * | low_gmxlibfn (const char *file, gmx_bool bAddCWD, gmx_bool bFatal) |
More flexible gmxlibfn(). More... | |
FILE * | low_libopen (const char *file, gmx_bool bFatal) |
Alternative for libopen() that optionally does not exit. More... | |
FILE * | gmx_fopen_temporary (char *buf) |
Creates unique name for temp file (wrapper around mkstemp) and opens it. More... | |
void | gmx_tmpnam (char *buf) |
Creates unique name for temp file (wrapper around mkstemp). More... | |
int | gmx_file_rename (const char *oldname, const char *newname) |
OS-independent rename(). More... | |
int | gmx_file_copy (const char *oldname, const char *newname, gmx_bool copy_if_empty) |
Copies a file (data only) oldname to newname. More... | |
int | gmx_fsync (FILE *fp) |
OS-independent fsync(). More... | |
void | gmx_chdir (const char *directory) |
OS-independent chdir(). More... | |
void | gmx_getcwd (char *buffer, size_t size) |
OS-independent getcwd(). More... | |
const DataFileFinder & | gmx::getLibraryFileFinder () |
Gets a finder for locating data files from share/top/. More... | |
void | gmx::setLibraryFileFinder (const DataFileFinder *finder) |
Sets a finder for location data files from share/top/. More... | |
typedef gmx_int64_t gmx_off_t |
GROMACS definition to use instead of off_t
.
void frewind | ( | FILE * | fp | ) |
Wraps rewind() for files opened with gmx_ffopen().
A fatal error results if this function is called for a pipe (a compressed input file).
void gmx_chdir | ( | const char * | directory | ) |
OS-independent chdir().
Exits with a fatal error if changing the directory fails.
void gmx_disable_file_buffering | ( | void | ) |
Turn off buffering for output files (which is default) for debugging purposes.
This only has effect on files opened with gmx_ffopen().
gmx_bool gmx_fexist | ( | const char * | fname | ) |
Check whether a path exists.
TRUE
when fname
exists.Note that this returns TRUE
even if fname
is a directory instead of a file.
int gmx_ffclose | ( | FILE * | fp | ) |
Closes a file opened with gmx_ffopen().
FILE* gmx_ffopen | ( | const char * | file, |
const char * | mode | ||
) |
Opens a file, with GROMACS-specific additions.
If the file is in compressed format, opens a pipe which uncompresses the file on the fly. For this to work, gmx_ffclose() and frewind() should always be used for files opened with gmx_ffopen() instead of fclose() and rewind(). For compressed files, the file
parameter should be passed without the compressed extension; if that file is not found, then a few compression extensions are tried. Creates a backup if a file opened for writing already exists before overwriting it. A fatal error results if the file cannot be opened, for whatever reason.
int gmx_file_copy | ( | const char * | oldname, |
const char * | newname, | ||
gmx_bool | copy_if_empty | ||
) |
Copies a file (data only) oldname to newname.
If copy_if_empty
is FALSE
, the file won't be copied if it's empty.
int gmx_file_rename | ( | const char * | oldname, |
const char * | newname | ||
) |
OS-independent rename().
Renames/moves a file atomically, if the OS makes that available.
FILE* gmx_fopen_temporary | ( | char * | buf | ) |
Creates unique name for temp file (wrapper around mkstemp) and opens it.
buf
should be at least 7 bytes long
int gmx_fseek | ( | FILE * | stream, |
gmx_off_t | offset, | ||
int | whence | ||
) |
OS-independent 64-bit fseek().
int gmx_fsync | ( | FILE * | fp | ) |
OS-independent fsync().
Only use this during checkpointing!
gmx_off_t gmx_ftell | ( | FILE * | stream | ) |
OS-independent 64-bit ftell().
void gmx_getcwd | ( | char * | buffer, |
size_t | size | ||
) |
OS-independent getcwd().
Exits with a fatal error if the call fails.
void gmx_set_max_backup_count | ( | int | count | ) |
Enables backups with the specified number of maximum backups.
If count
== 0, disables backups. If not called, this is the default. If count
== -1, reads the count from an environment variable.
This is not currently thread-safe, as it is only called during initialization code.
void gmx_tmpnam | ( | char * | buf | ) |
Creates unique name for temp file (wrapper around mkstemp).
buf
should be at least 7 bytes long
int gmx_truncate | ( | const char * | filename, |
gmx_off_t | length | ||
) |
OS-independent truncate().
char* gmxlibfn | ( | const char * | file | ) |
Finds full path for a library file.
Searches first in the current directory, and then in the configured library directories. Fatal error results if the file is not found in any location. The caller is responsible of freeing the returned string.
FILE* libopen | ( | const char * | file | ) |
Opens a library file for reading.
Works as gmxlibfn(), except that it opens the file and returns a file handle.
More flexible gmxlibfn().
Works as gmxlibfn(), but provides control whether the current working directory is searched or not, and whether a missing file is a fatal error or not.