Surely it would be simpler to store all this info in a database table? e.g.

 id       : int
 created  : timestamp
 filename : varchar

Only files that actually existed would be in the DB, plus you could do all
your sorting on the 'created' timestamp column. Querying the DB should be
much simpler and more efficient than using the filesystem.

Aside from anything else, it would make your program a lot easier to
understand to anyone having to maintain it in the future.

Edward

> Edward Kay wrote:
> > Are all the files called file.xxxx.jpg or could they have other
> names such
> > as clouds.1123.jpg, field.2034.jpg etc?
>     They are all the same exact file name with the only difference being
> the timestamp.
>
> > Alternatively, you could get the OS to do the work through an
> exec call to
> > something like 'ls *.????.jpg' or similar. The downside of this
> however is
> > that it is then OS dependent.
>     I thought of that too, but only because of the way the files are
> stored.  I completely forgot about one other catch...  I thought about
> it but my hands were too quick and I didn't type that paragraph in.
>
>     The files are stored as follows on the file system:
>
>     /.year/month/day/hour/file.hhmm.jpg   (yes that dot preceding year
> is correct)
>
>     So I can look right now and find /.2006/11/15/08/file.0846.jpg
>
>     Each /hour/ folder contains at most 60 files so in essence doing
> either a scandir() or an exec call to ls wouldn't take that long.
> However, I run into problems when I need to traverse to the previous
> hour to find images.
>
>     Say I load up a file with timestamp 0802.  I now need to find 0801,
> 0800, 0759, 0758, and 0757.  The last three being in the previous
> folder.  Unless I run scandir() again the entire /day/ folder and sort,
> I'd have to figure out how to go on about that.
>
>     Like I said, I completely forgot to write this piece of the puzzle
> in my previous e-mail.  I blame it on the lack of caffeine.
>
>     -- A
>
> --
> W | It's not a bug - it's an undocumented feature.
>   +--------------------------------------------------------------------
>   Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
>   IT Director / SysAdmin / Websmith             .     800.441.3873 x130
>   Photo Craft Imaging                       .     3550 Arapahoe Ave. #6
>   http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to