Callback for CopyDirectory and DeleteDirectory

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Callback for CopyDirectory and DeleteDirectory

Post 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
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post 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 ()) 
;)
SPAMINATOR NR.1
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Hey. I collected it many years. :P
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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.
Tranquil
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Callback for CopyDirectory and DeleteDirectory

Post 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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: Callback for CopyDirectory and DeleteDirectory

Post 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.
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re:

Post 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
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Callback for CopyDirectory and DeleteDirectory

Post 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])
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Post Reply