3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * Gromacs Runs On Most of All Computer Systems
50 /* Native windows uses backslash path separators.
51 * Cygwin and everybody else in the world use slash.
52 * When reading the PATH environment variable, Unix separates entries
53 * with colon, while windows uses semicolon.
55 #if ((defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64) && !defined __CYGWIN__ && !defined __CYGWIN32__)
56 #define DIR_SEPARATOR '\\'
57 #define PATH_SEPARATOR ";"
59 #define DIR_SEPARATOR '/'
60 #define PATH_SEPARATOR ":"
64 /* Now get the maximum path size. */
66 #define GMX_PATH_MAX PATH_MAX
69 #define GMX_PATH_MAX MAX_PATH
71 #define GMX_PATH_MAX 4096
76 extern void no_buffers(void);
77 /* Turn off buffering of files (which is default) for debugging purposes */
79 extern bool gmx_fexist(const char *fname
);
80 /* Return TRUE when fname exists, FALSE otherwise */
82 bool gmx_fexist_master(const char *fname
, t_commrec
*cr
);
83 /* Return TRUE when fname exists, FALSE otherwise, bcast from master to others */
85 extern bool gmx_eof(FILE *fp
);
86 /* Return TRUE on end-of-file, FALSE otherwise */
88 extern bool is_pipe(FILE *fp
);
89 /* Check whether the file (opened by ffopen) is a pipe */
91 /* Make a backup of file if necessary.
92 Return false if there was a problem.
94 extern bool make_backup(const char * file
);
96 extern FILE *ffopen(const char *file
, const char *mode
);
97 /* Return a valid file pointer when successful, exits otherwise
98 * If the file is in compressed format, open a pipe which uncompresses
99 * the file! Therefore, files must be closed with ffclose (see below)
102 extern int ffclose(FILE *fp
);
103 /* Close files or pipes */
106 extern void frewind(FILE *fp
);
107 /* Does not rewind pipes, but does so for normal files */
109 #define rewind frewind
111 bool is_pipe(FILE *fp
);
113 extern char *gmxlibfn(const char *file
);
114 /* allocates and returns a string with the full file name for a library file */
116 extern FILE *libopen(const char *file
);
117 /* Open a library file for reading. This looks in the current directory
118 * first, and then in the library directory. If the file is not found,
119 * it terminates with a fatal_error
122 extern bool get_libdir(char *libdir
);
124 extern char *low_gmxlibfn(const char *file
,bool bFatal
);
126 extern FILE *low_libopen(const char *file
,bool bFatal
);
127 /* The same as the above, but does not terminate if (!bFatal) */
129 /* Create unique name for temp file (wrapper around mkstemp).
130 * Buf should be at least 7 bytes long
132 extern void gmx_tmpnam(char *buf
);
134 /* truncte the file to the specified length */
135 int gmx_truncatefile(char *path
, off_t length
);
137 /* rename/move the file (atomically, if the OS makes that available) oldname
139 int gmx_file_rename(const char *oldname
, const char *newname
);
141 /* copy the file (data only) oldname to newname. if copy_if_empty==FALSE,
142 the file won't be copied if it's empty.*/
143 int gmx_file_copy(const char *oldname
, const char *newname
, bool copy_if_empty
);
149 #endif /* _futil_h */