void CheckAndSync::Syncronize(){ QStack <QFileInfo> File_Stack; QFileInfo backdir(".."); QDir *tempDir = new QDir(); tempDir->setCurrent("/home/quark/YaDiskDir"); tempDir->setFilter(QDir::Files| QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot); tempDir->setSorting(QDir::DirsLast); QVector <QString> VizitedDirs; qDebug() << QDateTime::currentDateTime().toString("ddd MMM dd hh:mm:ss yyyy")+" | "+"Begin to global syncronizing"; do { if (!VizitedDirs.contains(tempDir->path())) { File_Stack.push(backdir); for(int i=tempDir->entryInfoList().count();i>0;i--){ File_Stack.push(tempDir->entryInfoList().at(i-1)); if (File_Stack.top().isFile()) { if(tempDir->path() == "."){ emit NeedFilePropeties("/",File_Stack.pop().fileName()); qDebug() << QDateTime::currentDateTime().toString("ddd MMM dd hh:mm:ss yyyy")+" | "+"NeedFileProperties signal emmited"; } else { emit NeedFilePropeties('/'+tempDir->path()+'/',File_Stack.pop().fileName()); qDebug() << QDateTime::currentDateTime().toString("ddd MMM dd hh:mm:ss yyyy")+" | "+"NeedFileProperties signal emmited"; } } } } qDebug() << "CD to "+File_Stack.top().fileName(); VizitedDirs.append(tempDir->path()); tempDir->cd(File_Stack.pop().fileName()); } while(!File_Stack.empty()); qDebug() << QDateTime::currentDateTime().toString("ddd MMM dd hh:mm:ss yyyy")+" | "+"Global syncronizing complete.Waiting."; }
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 ); }
WORD doright( int flag ) { REG int ret,retmsg; char *temp, buf[14]; retmsg = TRUE; if (opcode == OP_DELETE) { temp = fixdst; fixdst = fixsrc; } if (flag == DTOD) { if (!(retmsg=doact())) goto endright; if (opcode != OP_COPY) retmsg = deleted(); /* rm the first folder */ } else /* file to file */ { getlastpath(filestr, fixdst); backdir(fixdst); getlastpath(buf, fixdst); strcat(filestr, fixdst); updatname(CPFILE, filestr); updatname(CPDIR, buf); if ( opcode != OP_DELETE ) if ((!(retmsg = wrfile(filestr)))||(rename)||(retmsg == SKIP)) goto endright; if (opcode != OP_COPY) { redel: if ( (ret = (WORD)Fdelete(fixsrc)) ) { /* seek error or drive not ready */ /* if ( (ret == E_SEEK) || (ret == EDRVNR) ) { retmsg = FALSE; goto endright; } */ if ( ( ret = fill_string( fixsrc, CNTDELF ) ) == 2 ) goto redel; if ( ret == 1 ) /* skip */ retmsg = SKIP; else { f_abort = 1; retmsg = FALSE; } goto endright; /* error */ } else { if (opcode == OP_DELETE) updatnum(NUMFILE, --numfiles); } } if ( retmsg == TRUE ) { /* if ( opcode == OP_MOVE ) upfdesk( fixsrc, fixdst ); */ if ( opcode == OP_DELETE ) upfdesk( fixsrc, (BYTE*)0 ); } } endright: free(fixsrc); if (opcode == OP_DELETE) free(temp); else free(fixdst); return(retmsg); }
int edname(char *src, int kind, int change) { int but; REG OBJECT *obj; obj = get_tree( SAMENAME ); pack(src, 0); strcpy(src, (BYTE *)((TEDINFO *)(obj[FNAME].ob_spec))->te_ptext); strcpy(src, (BYTE *)((TEDINFO *)(obj[EDFNAME].ob_spec))->te_ptext); /* obj[COPY].ob_state = NORMAL; obj[SKIP].ob_state = NORMAL; obj[QUIT].ob_state = NORMAL; */ ((TEDINFO*)(obj[SNAME].ob_spec))->te_ptext = (LONG)get_fstring( ( change ) ? RNAME : NCONFLIC ); /* desk_mice( ARROW ); */ /* fm_draw( SAMENAME, FALSE ); */ switch( but = fmdodraw( SAMENAME, 0 ) ) { case COPY: if (!strcmp((BYTE *)((TEDINFO *)(obj[EDFNAME].ob_spec))->te_ptext, src)) { /* user edit the new name */ strcpy( (BYTE *)((TEDINFO *)(obj[EDFNAME].ob_spec))->te_ptext,src); strcpy( src, (BYTE *)((TEDINFO *)(cpbox[kind].ob_spec))->te_ptext); pack(src,1); backdir(fixdst); strcat(src, fixdst); but = CHECK; } else {/* check if the source and destination are the same */ if (kind == CPDIR) rmstarb(fixsrc); if (strcmp(fixsrc, fixdst))/* they are the same */ but = SKIP; if (kind == CPDIR) strcat(bckslsh, fixsrc); } break; case SKIP: case QUIT: break; } /* desk_mice( HOURGLASS ); */ if ( d_display ) { draw_loop( whandle, cpbox, 0, MAX_DEPTH, 0, 0, full.g_w, full.g_h ); /* fm_draw( CPBOX, FALSE ); */ } /* else namecon = TRUE; */ if (but != CHECK) pack(src, 1); return but; }