// IfsBackupCmd5.bcpl -- operator interface for backup system
// Copyright Xerox Corporation 1981

// Last modified January 31, 1981  5:58 PM by Taft


get "Ifs.decl"

external
[
// outgoing procedures
BackupOnLine; BackupOffLine; BackupList

// incoming procedures
ExecList
OpenIFS; CloseIFS
GetString; AbortCmd
FreePointer
Wss; Puts; IFSPrintError; PutTemplate; WritePackedDT

// incoming statics
dsp
]


//----------------------------------------------------------------------------
let BackupOnLine(cs, lvOpenedFS) be
//----------------------------------------------------------------------------
[
if @lvOpenedFS ne 0 then
   [ CloseIFS(@lvOpenedFS); @lvOpenedFS = 0 ]
Wss(cs, " (file system) ")
let name = GetString(cs, 0, Wss, "pack name")
let ec = nil
let fs = OpenIFS(name, lv ec)
FreePointer(lv name)
if fs eq 0 then
   [ Puts(dsp, $*n); IFSPrintError(dsp, ec); AbortCmd(cs) ]

@lvOpenedFS = fs
PutTemplate(dsp, "*n$S ($S), initialized on $P.",
 fs>>IFS.id, fs>>IFS.name, WritePackedDT, lv fs>>IFS.created)
]

//----------------------------------------------------------------------------
and BackupOffLine(cs, lvOpenedFS) be
//----------------------------------------------------------------------------
[
if @lvOpenedFS ne 0 then
   unless CloseIFS(@lvOpenedFS) do
      AbortCmd(cs, " -- failed: open files exist.")
@lvOpenedFS = 0
]

//----------------------------------------------------------------------------
and BackupList(cs, lvOpenedFS) be
//----------------------------------------------------------------------------
[
if @lvOpenedFS eq 0 then 
   AbortCmd(cs, "*nPlease issue an OnLine command first.")
ExecList(cs, @lvOpenedFS)
]