int gmx_fio_get_output_file_positions(gmx_file_position_t **p_outputfiles, int *p_nfiles) { int i, nfiles, rc, nalloc; int pos_hi, pos_lo; long pos; gmx_file_position_t * outputfiles; char buf[STRLEN]; t_fileio *cur; nfiles = 0; /* pre-allocate 100 files */ nalloc = 100; snew(outputfiles, nalloc); cur = gmx_fio_get_first(); while (cur) { /* Skip the checkpoint files themselves, since they could be open when we call this routine... */ /* also skip debug files (shoud be the only iFTP==efNR) */ if (cur->bOpen && !cur->bRead && !cur->bStdio && cur->iFTP != efCPT && cur->iFTP != efNR) { int ret; /* This is an output file currently open for writing, add it */ if (nfiles == nalloc) { nalloc += 100; srenew(outputfiles, nalloc); } strncpy(outputfiles[nfiles].filename, cur->fn, STRLEN - 1); /* Get the file position */ gmx_fio_int_get_file_position(cur, &outputfiles[nfiles].offset); #ifndef GMX_FAHCORE outputfiles[nfiles].chksum_size = gmx_fio_int_get_file_md5(cur, outputfiles[nfiles].offset, outputfiles[nfiles].chksum); #endif nfiles++; } cur = gmx_fio_get_next(cur); } *p_nfiles = nfiles; *p_outputfiles = outputfiles; return 0; }
int gmx_fio_check_file_position(t_fileio *fio) { /* If gmx_off_t is 4 bytes we can not store file offset > 2 GB. * If we do not have ftello, we will play it safe. */ #if (SIZEOF_GMX_OFF_T == 4 || !defined HAVE_FSEEKO) gmx_off_t offset; gmx_fio_lock(fio); gmx_fio_int_get_file_position(fio, &offset); /* We have a 4 byte offset, * make sure that we will detect out of range for all possible cases. */ if (offset < 0 || offset > 2147483647) { fio->bLargerThan_off_t = TRUE; } gmx_fio_unlock(fio); #endif return 0; }