* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
-#ifdef HAVE_CONFIG_H
+#include "gmxpre.h"
+
+#include "gromacs/utility/futil.h"
+
#include "config.h"
-#endif
#include <stdio.h>
#include <stdlib.h>
#include "thread_mpi/threads.h"
-#include "gromacs/legacyheaders/gmx_fatal.h"
-#include "gromacs/legacyheaders/types/commrec.h"
-#include "gromacs/legacyheaders/network.h"
-
-#include "gromacs/fileio/futil.h"
-#include "gromacs/fileio/path.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/path.h"
#include "gromacs/utility/programcontext.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
} t_pstack;
static t_pstack *pstack = NULL;
-static gmx_bool bUnbuffered = FALSE;
+static bool bUnbuffered = false;
/* this linked list is an intrinsically globally shared object, so we have
to protect it with mutexes */
static tMPI_Thread_mutex_t pstack_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
-void no_buffers(void)
+void gmx_disable_file_buffering(void)
{
- bUnbuffered = TRUE;
+ bUnbuffered = true;
}
void push_ps(FILE *fp)
}
-#ifdef rewind
-#undef rewind
-#endif
-
void frewind(FILE *fp)
{
tMPI_Thread_mutex_lock(&pstack_mutex);
#endif
}
-
-gmx_bool is_pipe(FILE *fp)
-{
- tMPI_Thread_mutex_lock(&pstack_mutex);
-
- t_pstack *ps = pstack;
- while (ps != NULL)
- {
- if (ps->fp == fp)
- {
- tMPI_Thread_mutex_unlock(&pstack_mutex);
- return TRUE;
- }
- ps = ps->prev;
- }
- tMPI_Thread_mutex_unlock(&pstack_mutex);
- return FALSE;
-}
-
-
static FILE *uncompress(const char *fn, const char *mode)
{
FILE *fp;
}
}
-
-gmx_bool gmx_fexist_master(const char *fname, t_commrec *cr)
-{
- gmx_bool bExist;
-
- if (SIMMASTER(cr))
- {
- bExist = gmx_fexist(fname);
- }
- if (PAR(cr))
- {
- gmx_bcast(sizeof(bExist), &bExist, cr);
- }
- return bExist;
-}
-
-gmx_bool gmx_eof(FILE *fp)
-{
- char data[4];
- gmx_bool beof;
-
- if (is_pipe(fp))
- {
- return feof(fp);
- }
- else
- {
- if ((beof = fread(data, 1, 1, fp)) == 1)
- {
- gmx_fseek(fp, -1, SEEK_CUR);
- }
- return !beof;
- }
-}
-
static char *backup_fn(const char *file, int count_max)
{
/* Use a reasonably low value for countmax; we might
/* name in Buf should now be OK */
}
-int gmx_truncatefile(char *path, gmx_off_t length)
-{
-#ifdef GMX_NATIVE_WINDOWS
- /* Microsoft visual studio does not have "truncate" */
- HANDLE fh;
- LARGE_INTEGER win_length;
-
- win_length.QuadPart = length;
-
- fh = CreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, NULL,
- OPEN_EXISTING, 0, NULL);
- SetFilePointerEx(fh, win_length, NULL, FILE_BEGIN);
- SetEndOfFile(fh);
- CloseHandle(fh);
-
- return 0;
-#else
- return truncate(path, length);
-#endif
-}
-
-
int gmx_file_rename(const char *oldname, const char *newname)
{
#ifndef GMX_NATIVE_WINDOWS
rc = fah_fsync(fp);
#else /* GMX_FAHCORE */
{
- int fn = -1;
+ int fn;
/* get the file number */
#if defined(HAVE_FILENO)
fn = fileno(fp);
#elif defined(HAVE__FILENO)
fn = _fileno(fp);
+#else
+ fn = -1;
#endif
/* do the actual fsync */