19
23
this_entry = psio_unit[unit].toc;
21
25
while(this_entry != NULL) {
23
this_entry = this_entry->next;
27
this_entry = this_entry->next;
34
** PSIO_RD_TOCLEN(): Read the length of the TOC for a given unit directly from the file.
36
** \param unit = PSI unit number from which to read the toclen.
38
** NB: Note that we do not exit if the read request of the toclen from
39
** the file fails. This is because the request may be to an new file
40
** for which the toclen has not yet been written. (We allow the user
41
** to open files with status PSIO_OPEN_OLD even if they don't exist,
42
** because sometimes you can't know this in advance.)
46
ULI psio_rd_toclen(unsigned int unit)
52
this_unit = &(psio_unit[unit]);
54
/* Seek vol[0] to its beginning */
55
stream = this_unit->vol[0].stream;
56
errcod = lseek(stream, 0L, SEEK_SET);
57
if(errcod == -1) psio_error(unit,PSIO_ERROR_LSEEK);
60
errcod = read(stream, (char *) &toclen, sizeof(ULI));
61
if(errcod != sizeof(ULI)) return(0); /* assume that all is well (see comments above) */
67
** PSIO_WT_TOCLEN(): Write the length of the TOC for a given unit directly to the file.
69
** \param unit = PSI unit number to which to write the toclen.
73
void psio_wt_toclen(unsigned int unit, ULI toclen)
78
this_unit = &(psio_unit[unit]);
80
/* Seek vol[0] to its beginning */
81
stream = this_unit->vol[0].stream;
82
errcod = lseek(stream, 0L, SEEK_SET);
84
fprintf(stderr, "Error in PSIO_WT_TOCLEN()!\n");
85
exit(PSI_RETURN_FAILURE);
89
errcod = write(stream, (char *) &toclen, sizeof(ULI));
90
if(errcod != sizeof(ULI)) {
91
fprintf(stderr, "PSIO_ERROR: Failed to write toclen to unit %d.\n", unit);
92
psio_error(unit,PSIO_ERROR_WRITE);