int Drmvdup(Dlink *L,int size){ D_l *tmp,*tmp1; char *pt,*pt1; int i=0; tmp = L->st; while(tmp !=NULL) { pt = (char *)(tmp->bf); if(tmp !=L->en) { tmp1= tmp->nx; while(tmp1 != NULL) { pt1 = (char *)(tmp1->bf); for(i=0;i<size;i++) if( pt[i] != pt1[i]) break; if( i==size){ L->cr=tmp1; if(tmp1 == L->en){ Ddelete(L); break; } /* in case last one is deleted */ Ddelete(L); tmp1 = L->cr; } else tmp1 = tmp1->nx; } } tmp = tmp->nx; } return 1; }
WORD deleted( VOID ) { int ret; char buffer[14]; rmstarb( fixsrc ); /* remove back slash */ if ( !fixsrc[2] ) /* at the root ? */ return( TRUE ); getlastpath( buffer, fixsrc ); updatbox( buffer ); domore: if ( Ddelete(fixsrc) ) { /* retry */ if ( ( ret = fill_string( fixsrc, CNTDELD ) ) == 2 ) goto domore; else if ( ret == 3 ) /* abort */ { f_abort = 1; return(FALSE); } } else upfdesk( fixsrc, (BYTE*)0 ); if ( opcode == OP_DELETE ) updatnum(NUMDIR, --numdirs); return(TRUE); }
int x_rmdir(const char *path) { #if USE_gemdos return xerror((int) gemdos(58, path)); #else return xerror(Ddelete(path)); #endif }
void Dreplace(Disc *d, Posn p1, Posn p2, Rune *addr, int n) { int i, nb, nr; Posn p = 0; Rune buf[BLOCKSIZE]; if(p2-p1 > n) Ddelete(d, p1+n, p2); else if(p2-p1 < n) Dinsert(d, 0, n-(p2-p1), p2); if(n == 0) return; p2 = p1+n; /* they're now conformal; replace in place */ for(i=0; i<d->block.nused; i++){ if((p+=d->block.blkptr[i].nrunes) > p1){ p -= d->block.blkptr[i].nrunes; goto out; } } panic("Dreplace"); out: if(p != p1){ /* trailing partial block */ nb = d->block.blkptr[i].nrunes; bkread(d, buf, nb, i, 0); if(p2 > p+nb) nr = nb-(p1-p); else nr = p2-p1; memmove(buf+p1-p, addr, RUNESIZE*nr); bkwrite(d, buf, nb, i, 0); /* advance to next block */ p += nb; addr += nr; i++; } /* whole blocks */ while(p<p2 && (nb = d->block.blkptr[i].nrunes)<=p2-p){ if(i >= d->block.nused) panic("Dreplace 2"); bkwrite(d, addr, nb, i, 0); p += nb; addr += nb; i++; } if(p < p2){ /* any initial partial block left? */ nr = p2-p; nb = d->block.blkptr[i].nrunes; /* just read in the part that survives */ bkread(d, buf+nr, nb-nr, i, nr); memmove(buf, addr, RUNESIZE*nr); bkwrite(d, buf, nb, i, 0); } }
int Drmvdup_cond(Dlink *L,int rule(void *,void *)){ D_l *tmp,*tmp1; tmp = L->st; while(tmp !=NULL) { if(tmp !=L->en) { tmp1= tmp->nx; while(tmp1 != NULL) { if( rule(tmp->bf,tmp1->bf)==1) { L->cr=tmp1; if(tmp1 == L->en){ Ddelete(L); break; } /* in case last one is deleted */ Ddelete(L); tmp1 = L->cr; if(tmp1 == L->en) break; } else tmp1 = tmp1->nx; } } tmp = tmp->nx; } return 1; }
void Bdelete(Buffer *b, Posn p1, Posn p2) { if(p1<0 || p2<0) panic("Bdelete p<0"); if(b->c2>b->disc->nrunes || b->c1>b->disc->nrunes) panic("bdelete cache"); if(p1 == p2) return; if(incache(b, p1, p2)){ Strdelete(&b->cache, p1-b->c1, p2-b->c1); b->dirty = TRUE; }else{ Bflush(b); Ddelete(b->disc, p1, p2); b->cache.n = 0; b->c1 = b->c2 = 0; } b->nrunes -= p2-p1; }
int doact( VOID ) { /* char *saved; */ DMABUFFER *dumb, * saved; REG int ret, retmsg; int error; if ( f_level >= ( COPYMAXDEPTH + 1 ) ) { act_1: do1_alert( STFO8DEE ); return( FALSE ); } /* changed CHAR * to DMABUFFER * in expression below - JTT */ if ( !( dumb = (DMABUFFER *)malloc( (LONG)sizeof( DMABUFFER ) ) ) ) goto act_1; f_level++; retmsg = TRUE; saved = (DMABUFFER *)Fgetdta(); Fsetdta( dumb ); strcat(getall, fixsrc); if ( !( error = Fsfirst(fixsrc, 0x37) ) ) { do { if ( !ch_undo( ) || f_cancel ) /* user want to abort */ { f_abort = 1; retmsg = FALSE; goto mvend; } if (dumb->d_fname[0] != HOME) { if (SUBDIR & dumb->d_fattr) { chkbuf(srclen, srcbuf, &fixsrc); /* check buf size */ addfile(fixsrc, dumb->d_fname); /* add a dir into the path */ strcat(bckslsh, fixsrc); if (opcode != OP_DELETE) { chkbuf(dstlen, dstbuf, &fixdst); /* check buf size */ strcat(dumb->d_fname, fixdst); } else goto dorec; updatbox(dumb->d_fname); rechkd1: /* update check the dir existing or not */ switch( chkdf( dumb->d_fname, CPDIR ) ) { case QUIT: f_abort = 1; retmsg = FALSE; goto mvend; case SKIP: backdir(fixsrc); backdir(fixdst); updatnum(NUMDIR, --numdirs); srclen -= FILE_LEN; /* subtract the add lenth */ dstlen -= FILE_LEN; /* subtract the add lenth */ retmsg = TRUE; continue; case FALSE: goto mvend; case CHECK: goto rechkd1; case OK: recrtd: if (Dcreate(fixdst)) { if ( write_save ) goto kk_1; switch( fill_string( fixdst, CNTCRTDR ) ) { case 1: /* skip */ backdir(fixsrc); backdir(fixdst); updatnum(NUMDIR, --numdirs); srclen -= FILE_LEN; /* subtract the add lenth */ dstlen -= FILE_LEN; /* subtract the add lenth */ continue; case 2: /* retry */ goto recrtd; default: /* quit */ f_abort = 1; retmsg = FALSE; goto mvend; }/* switch */ }/* if recrtd */ break; } kk_1: updatnum(NUMDIR, --numdirs); strcat(bckslsh, fixdst); dorec: if (!doact()) /* do the recursion */ { retmsg = FALSE; goto mvend; } if (opcode == OP_COPY) goto clndir; rmstarb(fixsrc); /* after call, -> c:\d1\ */ if (opcode == OP_DELETE) { getlastpath(filestr, fixsrc); updatbox(filestr); } remvd: if (Ddelete(fixsrc)) { /* delete a dir */ if ( ( ret = fill_string( fixsrc, CNTDELD ) ) == 2 ) goto remvd; /* retry */ else if (ret == 3) { /* abort */ f_abort = 1; retmsg = FALSE; goto mvend; } } else /* No error */ upfdesk( fixsrc, (BYTE*)0 ); clndir: backdir(fixsrc); /* back one dir */ srclen -= FILE_LEN; /* subtract the add lenth */ if (opcode == OP_DELETE) updatnum(NUMDIR, --numdirs); else { backdir(fixdst); /* back one dir */ dstlen -= FILE_LEN; /* subtract the add lenth */ } } else { getlastpath(filestr, fixdst); updatname(CPDIR, filestr); /* update the dir */ updatname( CPFILE, dumb->d_fname ); /* update the file */ chkbuf(srclen, srcbuf, &fixsrc); /* check buf size */ addfile(fixsrc, dumb->d_fname); if (opcode != OP_DELETE) { chkbuf(dstlen, dstbuf, &fixdst); /* check buf size */ addfile(fixdst, dumb->d_fname); rename = 0; if (!(retmsg = wrfile(dumb->d_fname))) goto mvend; if ((rename) || (retmsg == SKIP)) goto clnfile; } if (opcode == OP_COPY) goto clnfile; remvf: if (ret = (WORD)(Fdelete(fixsrc))) /* rm the file from source */ { /* seek error or drive not ready */ /* if ((ret == E_SEEK) || (ret == EDRVNR)) { retmsg = FALSE; goto mvend; } */ /* retry */ if ( ( ret = fill_string( fixsrc, CNTDELF ) ) == 2 ) goto remvf; else if ( ret == 3 ) { /* abort */ f_abort = 1; retmsg = FALSE; goto mvend; } } else upfdesk( fixsrc, (BYTE*)0 ); clnfile: backdir(fixsrc); /* back one dir */ srclen -= FILE_LEN; /* subtract the add lenth */ if (opcode == OP_DELETE) updatnum(NUMFILE, --numfiles); else { backdir(fixdst); /* back one dir */ dstlen -= FILE_LEN; /* subtract the add lenth */ } } } } while (!Fsnext()); } else { if ( error != EFILNF ) /* if not file not found */ retmsg = FALSE; /* then return error */ } mvend: Fsetdta( saved ); f_level--; free( dumb ); return( retmsg ); }