DataMuseum.dk

Presents historical artifacts from the history of:

Regnecentalen RC-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Regnecentalen RC-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦1e499b89b⟧ TextFile

    Length: 1506 (0x5e2)
    Types: TextFile
    Notes: UNIX file
    Names: »save.file«

Derivation

└─⟦bee8f15db⟧ Bits:30004169/disk2.imd Uniplex II+ V.6 release 1.0 (dansk)
└─⟦bee8f15db⟧ UNIX Filesystem
    └─⟦this⟧ »up/new/usr/UAP/install.cmds/save.file« 

TextFile


: 'save.file - save file in a directory, ensure it is given a unique
               name

L..T..T..T..T..T..T..T..T..T..T..T..T..T..T..T..T..T..T..T..T..T..T..T..T..T..R

Usage:   save.file directory file

         "file" must be the simple name, no longer than 7 characters,
         of an existing file in "directory"

         the saved file will be named of the form file.NNN
         where NNN is an arbitrary decimal integer.
         The first save attempt will always be to "file.000000"
         If an attempt is made to save a "file" that is identical to an
         existing "file.000000", then "file" is simply removed

Exits:   undefined - always works! - assuming co-operative caller
         Will write informative message as required
'

DIR=$1
FILE=$2

case "$FILE" in
  ????????*) exec echo "FATAL ERROR: overlong file passed to $0: $2";;
esac

cd $DIR || exec echo "FATAL ERROR: $0 cannot CD to \"$1\""


if test -f $FILE.000000; then
   if cmp $FILE $FILE.000000 >/dev/null 2>&1 ; then
      : On identical .000000 file, just remove $FILE
      exec rm -f $FILE
   fi
: '
   Note - loop below will, in principle spin if all 999999 possible suffices
   are in use. The assumption is that no-one would have a file system with
   that many INODEs!!
'
   C=$$
   while test -f $FILE.$C; do
      C=`expr $C + 1`
      case "$C" in
        999999) C=0;;
      esac
   done
else
   C=000000
fi

echo "In folder \"$DIR\", saving existing file \"$FILE\" as \"$FILE.$C\""
mv $FILE $FILE.$C
exit