|
Posted by deciacco on 11/15/07 22:07
thanks for the reply steve...
basically, i want to collect the file information into memory so that I can
then do analysis, like compare file times and sizes. it's much faster to do
this in memory than to do it from disk. should have mentioned this earlier
as you said...
"Steve" <no.one@example.com> wrote in message
news:W93%i.227$dY3.203@newsfe02.lga...
>
> "deciacco" <a@a> wrote in message
> news:c6318fb5a59c46bf8a1e094964de9d6e@ghytred.com...
>> I'm writing a command line utility to move some files. I'm dealing with
>> thousands of files and I was wondering if anyone had any suggestions.
>>
>> This is what I have currently:
>>
>> $arrayVirtualFile =
>> array( 'filename'=>'filename',
>> 'basename'=>'filename.ext',
>> 'extension'=>'ext',
>> 'size'=>0,
>> 'dirname'=>'',
>> 'uxtimestamp'=>'');
>>
>> I then loop through a directory and for each file I populate the
>> $arrayVirtualFile
>> and add it to $arrayOfVirtualFiles.
>> A directory of ~2500 files takes up about ~1.7 MB of memory when I run
>> the script.
>> Anyone have any suggestions as to how to take up less space?
>
> well, that all depends what you're doing with that information. plus, your
> array structure is a must point. why not just store the file names in an
> array. when you need all that info, just use the pathinfo() function. with
> just that, so far you have the file name, basename, extension, path...all
> you need now is to call fstat() to get the size and the touch time. that
> should knock down your memory consumption monumentally. plus, using
> pathinfo and fstat will give you a bunch more information that your
> current structure.
>
> so, store minimally what you need. then use functions to get the info when
> you need it. but again, you should really define what you're doing this
> all for...as in, once you have that info, what are you doing?
>
Navigation:
[Reply to this message]
|