1
/*! \defgroup PSIO libpsio: The PSI I/O Library */
11
#include <libpsio/psio.h>
12
#include <libpsio/psio.hpp>
16
void PSIO::close(unsigned int unit, int keep) {
19
psio_tocentry *this_entry, *next_entry;
21
this_unit = &(psio_unit[unit]);
23
/* First check to see if this unit is already closed */
24
if (this_unit->vol[0].stream == -1)
25
psio_error(unit, PSIO_ERROR_RECLOSE);
27
/* Dump the current TOC back out to disk */
31
this_entry = this_unit->toc;
32
for (i=0; i < this_unit->toclen; i++) {
33
next_entry = this_entry->next;
35
this_entry = next_entry;
38
/* Close each volume (remove if necessary) and free the path */
39
for (i=0; i < this_unit->numvols; i++) {
41
if (::close(this_unit->vol[i].stream) == -1)
42
psio_error(unit,PSIO_ERROR_CLOSE);
44
/* Delete the file completely if requested */
45
if(!keep) unlink(this_unit->vol[i].path);
47
free(this_unit->vol[i].path);
48
this_unit->vol[i].path = NULL;
49
this_unit->vol[i].stream = -1;
52
/* Reset the global page stats to zero */
53
this_unit->numvols = 0;
54
this_unit->toclen = 0;
58
int psio_close(unsigned int unit, int keep) {
59
_default_psio_lib_->close(unit, keep);