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; }
/* * fio: file to compute md5 for * offset: starting pointer of region to use for md5 * digest: return array of md5 sum */ int gmx_fio_get_file_md5(t_fileio *fio, gmx_off_t offset, unsigned char digest[]) { int ret; gmx_fio_lock(fio); ret = gmx_fio_int_get_file_md5(fio, offset, digest); gmx_fio_unlock(fio); return ret; }