Effacer les filtres
Effacer les filtres

Estimate time of copy while using copyfile command

2 vues (au cours des 30 derniers jours)
Majid kh
Majid kh le 2 Fév 2019
Hi, How can i estimate time and bitrate of transfer files while using copyfile command? I saw some programs but they executed after Copyfile command that it`s not useful.

Réponses (1)

Walter Roberson
Walter Roberson le 2 Fév 2019
No, not using copyfile() itself, or any ActiveX or system interface that I can think of.
If you happen to have the Parallel Computing Toolbox, then you could start the copyfile in a second process using parfeval(). Then, while it is running, you can loop checking to see what the size is of the destination file so far, and comparing it to the size of the source file, and using the history of these to estimate and display the remaining time.
Another approach without the Parallel Computing Toolbox is to create a java thread to start the copyfile, and have your regular process do the same kind of monitoring I describe.
A third approach is to invoke system() to do the copying of the file, and giving the & special character as part of the command so that the copying happens in the background and the system() call returns immediately after it is started. Then the routine can do the same kind of monitoring I describe.
However, you might run into problems with monitoring the size of the file copied so far if you are using copyfile on Mac OS-X or MacOS. OS-X and MacOS copyfile in ways where the destination file is not made visible until the file copy is complete.
A completely different approach is to not use copyfile. Instead, fopen() the source and destination files and proceed to loop doing fread() of a chunk of data and fwrite() it, and update the statistics from time to time. This has the disadvantage that if the copying stalls (such as for network traffic) then you cannot get an update until the next time you make it through a chunk.

Catégories

En savoir plus sur Low-Level File I/O dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by