static void makbuf(FCB *f, DTAINFO *dt) { /* M01.01.03 */ dt->dt_fattr = f->f_attrib ; dt->dt_time = f->f_time ; swpw(dt->dt_time) ; dt->dt_date = f->f_date ; swpw(dt->dt_date) ; dt->dt_fileln = f->f_fileln ; swpl( dt->dt_fileln ) ; if( f->f_attrib & FA_VOL ) { memcpy(&dt->dt_fname[0], &f->f_name[0], 11); dt->dt_fname[11] = '\0' ; } else { packit(&f->f_name[0],&dt->dt_fname[0]); } }
/* ** makopn - make an open file for sft handle h ** */ static long makopn(FCB *f, DND *dn, int h, int mod) { OFD *p; OFD *p2; DMD *dm; /* M01.01.03 */ dm = dn->d_drv; p = MGET(OFD); /* MGET(OFD) only returns if it succeeds */ p->o_mod = mod; /* set mode */ p->o_dmd = dm; /* link OFD to media */ sft[h-NUMSTD].f_ofd = p; p->o_usecnt = 0; /* init usage */ p->o_curcl = 0; /* init file pointer info */ p->o_curbyt = 0; /* " */ p->o_dnode = dn; /* link to directory */ p->o_dirfil = dn->d_ofd; /* link to dir's ofd */ p->o_dirbyt = dn->d_ofd->o_bytnum - 32; /* offset of fcb in dir*/ for (p2 = dn->d_files; p2; p2 = p2->o_link) if (p2->o_dirbyt == p->o_dirbyt) break; /* same dir, same dcnt */ p->o_link = dn->d_files; dn->d_files = p; if (p2) { /* steal time/date,startcl,fileln (a bit clumsily) */ memcpy(&p->o_td,&p2->o_td,sizeof(DOSTIME)+sizeof(CLNO)+sizeof(long)); /* not used yet... TBA *********/ p2->o_thread = p; } else { p->o_strtcl = f->f_clust; /* 1st cluster of file */ swpw(p->o_strtcl); p->o_fileln = f->f_fileln; /* init length of file */ swpl(p->o_fileln); p->o_td.date = f->f_td.date; /* note: OFD time/date are */ p->o_td.time = f->f_td.time; /* actually little-endian! */ } return h; }
/* ** ixclose - ** ** Error returns EINTRN ** ** Last modified SCC 10 Apr 85 ** ** NOTE: I'm not sure that returning immediately upon an error from ** ixlseek() is the right thing to do. Some data structures may ** not be updated correctly. Watch out for this! ** Also, I'm not sure that the EINTRN return is ok. */ long ixclose(OFD *fd, int part) { /* M01.01.03 */ OFD *p, **q; int i; /* M01.01.03 */ BCB *b; /* * if the file or folder has been modified, we need to make sure * that the date/time, starting cluster, and file length in the * directory entry are updated. In addition, for files, we must * set the archive flag. * * The following code avoids multiple ixlseek()/ixlread()/ixlwrite() * sequences by just getting a pointer to a buffer containing the * FCB, and updating it directly. We must do an ixwrite() at the * end so that the buffer is marked as dirty and is subsequently * written. */ if (fd->o_flag & O_DIRTY) { FCB *fcb; UBYTE attr; ixlseek(fd->o_dirfil,fd->o_dirbyt); /* start of dir entry */ fcb = (FCB *)ixread(fd->o_dirfil,32L,NULL); attr = fcb->f_attrib; /* get attributes */ memcpy(&fcb->f_td,&fd->o_td,10); /* copy date/time, start, length */ swpw(fcb->f_clust); /* & fixup byte order */ swpl(fcb->f_fileln); if (part & CL_DIR) fcb->f_fileln = 0L; /* dir lengths on disk are zero */ else attr |= FA_ARCHIVE; /* set the archive flag for files */ ixlseek(fd->o_dirfil,fd->o_dirbyt+11); /* seek to attrib byte */ ixwrite(fd->o_dirfil,1,&attr); /* & rewrite it */ } if ((!part) || (part & CL_FULL)) { q = &fd->o_dnode->d_files; for (p = *q; p ; p = *(q = &p->o_link)) if (p == fd) break; /* someone else has this file open **** TBA */ if (p) *q = p->o_link; else return EINTRN; /* some kind of internal error */ } /* only flush to appropriate drive ***** TBA ******/ for (i = 0; i < 2; i++) for (b = bufl[i]; b; b = b->b_link) flush(b); return E_OK; }