Sign in to follow this  
Followers 0
piccaso

UDF: _GaugeCopy

1 post in this topic

#1 ·  Posted (edited)

Needs cp.exe From Unixtools (attached) to be in @ScriptDir or %PATH% to work.

No Multiple File support (jet?).

According to the docs of Unixtools cp.exe works only on NT, works nice on WinXP Sp1, can someone test other platforms?

and please tell me what you think.

is it usefull to someone else?

are the time and speed calculations correct? (not 100% sure about it)

suggestions? ... :)

Func _GaugeCopy($source, $dest)
    Local $RunErrorsFatalBackup, $sourcesize, $cppid, $destsize, $progress, $timer, $eta, $spd
    If FileExists($source) == 0 Then Return 0
    If FileExists($dest) == 1 Then Return 0
   $RunErrorsFatalBackup = Opt("RunErrorsFatal", 0)
    $cppid = Run(@ComSpec & ' /c cp "' & $source & '" "' & $dest & '"', @ScriptDir,@SW_HIDE)
    If @error = 1 Then
      Opt("RunErrorsFatal", $RunErrorsFatalBackup)
        Return 0
    EndIf
   Opt("RunErrorsFatal", $RunErrorsFatalBackup)
    $timer = TimerInit()
    $sourcesize = FileGetSize($source)
    If $sourcesize > 524288 Then
        ProgressOn($dest, "")
        While ProcessExists($cppid)
            Sleep(500)
            $destsize = FileGetSize($dest)
            $progress = Int(100 / $sourcesize * $destsize)
            $spd = Round($destsize * 1000 / TimerDiff($timer) / 1024, 2); kb/sec
            $eta = Round(Round($sourcesize - $destsize, 0) / 1024 / $spd, 2); sec
            If $spd > 1024 Then 
                $spd = Round($spd / 1024, 2) & " Mb/Sec"
            Else
                $spd = $spd & " Kb/Sec"
            EndIf
            If $eta > 0 Then
                If $eta > 60 Then 
                    $eta = Round($eta / 60, 0) & " Min"
                Else
                    $eta = $eta & " Sec"
                EndIf
            Else
                $eta = "";
            EndIf
            ProgressSet($progress, "Eta: " & $eta & " @ " & $spd)
        Wend
        ProgressOff()   
    EndIf
   if FileExists($dest) Then Return 1
EndFunc
Edited by piccaso

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0