Page 1 of 1

Callback for CopyDirectory and DeleteDirectory

Posted: Tue Nov 13, 2007 5:46 am
by Hroudtwolf
Hi,

I have a dream... ^^

It would be very useful to could use a optional callback-parameter with
CopyDirectory and DeleteDirectory.
I think, I should make an example.

Code: Select all

Procedure.l Callback (sFilename.s , lAttributes.l)
   Debug "File '" + sFilename + "' will copied."
   If lAttributes & #PB_File_System
      ProcedureReturn #False ; interrupt the copy-processs
   EndIf
    ProcedureReturn #True
EndProcedure

CopyDirectory ("c:\myfiles" , "c:\myporns")
CopyDirectory ("c:\myfiles" , "c:\myporns" , @Callback ())
Best regards

Wolf

Posted: Tue Nov 13, 2007 9:02 am
by Rings
instead

Code: Select all

CopyDirectory ("c:\myfiles" , "c:\myporns" , @Callback ()) 
it would be better to do this:

Code: Select all

DeleteDirectory ( "c:\myporns" , @Callback ()) 
;)

Posted: Tue Nov 13, 2007 2:42 pm
by Hroudtwolf
Hey. I collected it many years. :P

Posted: Tue Nov 13, 2007 6:30 pm
by Tranquil
If your wish comes true, it would also be nice to have a progress indicator inside the callback. (the actual reading/ writing location of the file should be enough I think)

Nice request indeed! I needed to code this all myselfe but this will keep a lot of work.

Re: Callback for CopyDirectory and DeleteDirectory

Posted: Wed Oct 19, 2016 11:20 am
by IdeasVacuum
+1
This is essential if the directory is large and/or multiple directories are recursively processed - you can't leave your User waiting for the function to finish without any indication of progress.

Re: Callback for CopyDirectory and DeleteDirectory

Posted: Wed Oct 19, 2016 11:33 am
by bbanelli
I don't think it's even possible with CopyFile() API used by PB. You can do it yourself by using CopyFileEx() or perhaps by utilizing ReadFileEx()WriteFileEx() procedures for Windows.

Re:

Posted: Wed Oct 19, 2016 11:37 am
by Dude
Having it native would be nice! :) But here's a workaround in the meantime: http://www.purebasic.fr/english/viewtop ... =7&t=66168

Re: Callback for CopyDirectory and DeleteDirectory

Posted: Thu Oct 20, 2016 1:54 am
by Lunasole
That's good idea, not sure only is it possible or not.
It would be nice a callback for ExamineDirectory() too (to filter files while examining and/or to filter symbolic links, etc).

Btw, generally "more callback, add a callback anywhere it is possible" sounds like a good way to improve PB libraries functionality by allowing user to have more low-level access if user wish so. But that's rather something like "a moment of development strategy" than feature request ^^
(and unlike most requests, it doesn't take much efforts to implement a callback [except maybe documentation, which can bring much work to @Andre :3])