From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/fmio/fmcopy.x | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 sys/fmio/fmcopy.x (limited to 'sys/fmio/fmcopy.x') diff --git a/sys/fmio/fmcopy.x b/sys/fmio/fmcopy.x new file mode 100644 index 00000000..1125a820 --- /dev/null +++ b/sys/fmio/fmcopy.x @@ -0,0 +1,37 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include "fmset.h" + +# FM_COPY -- Copy a datafile, preserving all the physical attributes, but +# eliminating waste storage and rendering file structures logically contiguous. + +procedure fm_copy (dfname, newname) + +char dfname[ARB] #I existing datafile +char newname[ARB] #I new datafile name + +pointer o_fm, n_fm +pointer fm_open() +int fm_stati() +errchk fm_open, fm_copyo + +begin + # Open the old and new datafiles. + o_fm = fm_open (dfname, READ_ONLY) + n_fm = fm_open (newname, NEW_FILE) + + # The child inherits the attributes of the parent. + call fm_seti (n_fm, FM_PAGESIZE, fm_stati(o_fm,FM_PAGESIZE)) + call fm_seti (n_fm, FM_MAXLFILES, fm_stati(o_fm,FM_MAXLFILES)) + + # Copy the datafile and clean up. + iferr (call fm_copyo (o_fm, n_fm)) { + call fm_close (o_fm) + call fm_close (n_fm) + call erract (EA_ERROR) + } else { + call fm_close (o_fm) + call fm_close (n_fm) + } +end -- cgit