回 帖 发 新 帖 刷新版面

主题:[原创]断点续拷II

DECLARE SUB Makelist (PathF$, PathT$)
DECLARE SUB CCopy (vFileF$, vFileT$)
DECLARE SUB Checkdir ()
DECLARE SUB Inlevel ()
DECLARE SUB ExitLevel ()
DECLARE SUB Checkfile ()
DECLARE SUB Createlist ()
DIM SHARED level, Dirpath$, PathFrom$, m, s, timeold
DIM SHARED Path$(100), PathD$(100)

'main program
ProgramStart:
timeold = TIMER
s = 0
CLS
PRINT "CCopy"
PRINT "Ver 2.0"
PRINT "Copyright(c)2005        GrapeOT"
PRINT "Warning:The files named CCOPYL*.dat in C:\ is needed by this program.Don't      try deleting them unless the program doesn't work."
PRINT "Warning:If you want to copy all the files in one certain directory,please make  sure the directory that you want to copy the files into exists."
PRINT "Warning:The program only support 8.3 file name system!!!"
PRINT "Continue Copy on"
OPEN "C:\CCopyLFF.dat" FOR APPEND AS #1
IF LOF(1) = 0 THEN
        CLOSE #1
        KILL "C:\CCopyLFF.dat"
        ELSE
        CLOSE #1
        PRINT "You have a copy work unfinished."
        PRINT "All the files in the copy work:"
        OPEN "C:\CCopyLFF.dat" FOR INPUT AS #1
        DO UNTIL EOF(1)
                INPUT #1, temp$
                PRINT temp$
                s = s + 1
        LOOP
        PRINT s; " file(s) in total."
        CLOSE #1
        OPEN "c:\CCopyLF.dat" FOR INPUT AS #2
        INPUT #2, m
        CLOSE #2
        PRINT s - m; " file(s) unfinished."
        PRINT "Do you want to continue the copy work?(Yes/No):";
        INPUT z$
        IF UCASE$(z$) = "Y" THEN
                ELSE
                KILL "c:\CCopyL*.dat"
                PRINT "The work has been cancelled."
                PRINT "Press any key to continue..."
                WHILE INKEY$ = "": WEND
                CLOSE
                SLEEP
                GOTO ProgramStart
        END IF
        OPEN "C:\CCopyLFF.dat" FOR INPUT AS #1
        OPEN "c:\CCopyLFT.dat" FOR INPUT AS #2
        FOR i = 1 TO m
                INPUT #1, FileF$
                INPUT #2, FileT$
        NEXT i
        GOTO BeginCopy
END IF

INPUT "From"; PathFrom$
INPUT "To:"; PathTo$
CALL Makelist(PathFrom$, PathTo$)
IF INSTR(PathFrom$, ".") <> 0 THEN
        OPEN "c:\CCopyLFF.dat" FOR OUTPUT AS #1
        PRINT #1, PathFrom$
        CLOSE #1
END IF
PRINT "All the file(s) you want to copy:"
PRINT s; " file(s) in total."
PRINT
PRINT "Copy work begin..."

'MakeDIR
OPEN "c:\CCopyLDF.dat" FOR INPUT AS #1
DO UNTIL EOF(1)
        INPUT #1, dirtemp$
        MKDIR dirtemp$
LOOP
CLOSE #1

'Begin (C)Copy
OPEN "c:\CCopyLFF.dat" FOR INPUT AS #1
OPEN "c:\CCopyLFT.dat" FOR INPUT AS #2
BeginCopy:
DO UNTIL EOF(1)
        INPUT #1, FileF$
        INPUT #2, FileT$
        CALL CCopy(FileF$, FileT$)
LOOP
CLOSE
KILL "c:\ccopyl*.dat"
PRINT "Complete."
PRINT INT(TIMER - timeold); " seconds used."
END

SUB CCopy (vFileF$, vFileT$)
PRINT vFileF$
OPEN vFileF$ FOR BINARY AS #3
OPEN vFileT$ FOR BINARY AS #4
SEEK #3, LOF(4) + 1
SEEK #4, LOF(4) + 1
vlocate = INT(LOF(4) / (LOF(3) + 1) * 80)
PRINT STRING$(vlocate, ">");
DO UNTIL EOF(3)
        temp$ = INPUT$(10240, #3)
        PUT #4, , temp$
        IF INT(LOF(4) / (LOF(3) + 1) * 80) - vlocate > 0 THEN
                PRINT STRING$(INT(LOF(4) / (LOF(3) + 1) * 80) - vlocate, ">");
                vlocate = INT(LOF(4) / (LOF(3) + 1) * 80)
        END IF
LOOP
PRINT
CLOSE #3, #4
m = m + 1
OPEN "C:\CCopyLF.dat" FOR OUTPUT AS #5
PRINT #5, m
CLOSE #5
END SUB

SUB Checkdir
OPEN "GSDIR." + LTRIM$(STR$(level)) FOR INPUT AS #level
DO UNTIL EOF(level)
LINE INPUT #level, temp$
IF LTRIM$(temp$) <> temp$ OR temp$ = "" OR LEFT$(temp$, 1) = "." THEN
        ELSE
                IF MID$(temp$, 15, 3) = "DIR" THEN
                        Dirpath$ = RTRIM$(LEFT$(temp$, 8))
                        Inlevel
                END IF
        END IF
LOOP
CLOSE #level
KILL "GSDIR." + LTRIM$(STR$(level))
ExitLevel
END SUB

SUB Checkfile
OPEN "GSDIR." + LTRIM$(STR$(level)) FOR INPUT AS #level
DO UNTIL EOF(level)
LINE INPUT #level, temp$
IF LTRIM$(temp$) <> temp$ OR temp$ = "" OR LEFT$(temp$, 1) = "." THEN
        ELSE
                IF MID$(temp$, 15, 3) <> "DIR" THEN
                        vFNamea$ = RTRIM$(LEFT$(temp$, 8))
                        vFNameb$ = RTRIM$(MID$(temp$, 10, 3))
                        vFNameF$ = Path$(level) + "\" + vFNamea$ + "." + vFNameb$
                        vFNameT$ = PathD$(level) + "\" + vFNamea$ + "." + vFNameb$
                        IF vFNamea$ <> "GSDIR" AND UCASE$(vFNamea$) <> "CCOPYLDF" AND UCASE$(vFNamea$) <> "CCOPYLFF" AND UCASE$(vFNamea$) <> "CCOPYLFT" THEN
                        PRINT #1, vFNameF$
                        PRINT #3, vFNameT$
                        s = s + 1
                        END IF
                END IF
END IF
LOOP
CLOSE #level
END SUB

SUB Createlist
IF level = 1 THEN
        IF Path$(0) = "" THEN
                 SHELL "Dir " + Path$(level) + " >GSDIR." + LTRIM$(STR$(level))
                 ELSE
                 SHELL "Dir " + Path$(0) + " >GSDIR." + LTRIM$(STR$(level))
        END IF
        EXIT SUB
END IF
SHELL "Dir " + Path$(level) + " >GSDIR." + LTRIM$(STR$(level))
END SUB

SUB ExitLevel
Path$(level) = ""
level = level - 1
END SUB

SUB Inlevel
level = level + 1
Path$(level) = Path$(level - 1) + "\" + Dirpath$
PathD$(level) = PathD$(level - 1) + "\" + Dirpath$
PRINT #2, PathD$(level)
Createlist
Checkfile
Checkdir
END SUB

SUB Makelist (PathF$, PathT$)
OPEN "c:\CCopyLFF.dat" FOR OUTPUT AS #1
OPEN "c:\CCopyLDF.dat" FOR OUTPUT AS #2
OPEN "c:\CCopyLFT.dat" FOR OUTPUT AS #3
SPath$ = PathF$
IF RIGHT$(SPath$, 1) = "\" THEN SPath$ = LEFT$(SPath$, LEN(SPath$) - 1)
IF RIGHT$(SPath$, 1) = ":" THEN Path$(0) = SPath$ + "\"
Path$(4) = SPath$
SPath$ = PathT$
IF RIGHT$(SPath$, 1) = "\" THEN SPath$ = LEFT$(SPath$, LEN(SPath$) - 1)
IF RIGHT$(SPath$, 1) = ":" THEN PathD$(0) = SPath$ + "\"
PathD$(4) = SPath$
level = 4'+0

Createlist
Checkfile
Checkdir
CLOSE
END SUB

QB45编写
可以把一个目录下面的*.*,包括子目录完全拷到另一个目录下面。支持断点续传。
Win2k/QB45下调试通过。

回复列表 (共4个回复)

沙发

wa nb

板凳

[size=6]佩服![/size]

3 楼

麻烦你 给个注释 就算是本人,1个星期再去看,也不会知道自己要写什么了

4 楼

ding

我来回复

您尚未登录,请登录后再回复。点此登录或注册