> I'm writing a script that must list the files contained in a 
> folder. This 
> list should be ordered by timestamp of file creation  ( ie 
> file creation date).
> I have tried the following pseudo-code:
> initialize an array of structures: {creationdate, filename}
> opendir DIRNAME
> 
> @ListOfFiles = readdir DIRNAME
> foreach ( @ARRAY ) {
>      creationdate_structure = stat ( $_  )
>      create the new array element with creation date and file name
> }
> sort the new array
> 
> which is ok but extremely slow if I access to remote folders 
> thru the Local 
> Area Network because I have to access to 10s of thousands of files
> 
> 1) question # 1:
> does the output of readdir, without any sort, have any 
> specific order (by 
> chance creation date of the file?)
> 
> 2) question # 2
> if there any way to sort the contents of a folder by the 
> creation date of 
> the contained files?

The stat call in the C API that perl calls is unbelievably slow over wan
links. When writing an application to do this kind of work, I ended up
using Win32::API to encapsulate the Win32 API FindFirstFile and
FindNextFile calls (which stat presumably translates into at some
point), and got results that were much more in line with what you might
expect from the dir command or an app like Robocopy.

Let me know if you want to see some sample code.

Cheers,
Paul

*****************************************************************
Gloucester Research Limited believes the information 
provided herein is reliable. While every care has been 
taken to ensure accuracy, the information is furnished 
to the recipients with no warranty as to the completeness 
and accuracy of its contents and on condition that any 
errors or omissions shall not be made the basis for any 
claim, demand or cause for action.
*****************************************************************


_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to