Re: touch()ing it....advise needed.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You could just do a touch() on all the files with no test for
existence, if there will be a LOT of files...

That will save a little bit of work, and might be worthwhile info to
track, or at least not mess things up to have the filemtime altered
all the time.

Of course, you also need to be VERY careful with filename so that
something like:
../../../../../../etc/passwd
won't work.

On Sat, May 13, 2006 7:48 am, Ryan A wrote:
> Hey,
> Heres my setup, I have a directory full of files and I
> get a request with an array of filenames
> For this example:
> a.txt
> b.txt
> c.txt
>
> if the above files dont already exist I need to create
> them (I am using touch() instead of fopen())
>
> My question is which would you recommend, doing a
> readdir() and getting all the existing filenames in an
> array then doing a loop to see which exists and create
> the others OR
>
> just taking the new filenames, doing a while/for loop
> with a files_exists() on each and then creating the
> files....
>
> I am favouring the second approach as in the first
> approach there are a lot of files the array could be
> pretty big which would cause other problems, but I
> would rather be corrected now if my thinking is
> flawed.
>
> Your advise appreciated.
>
> Thanks!
> Ryan
>
> ------
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
> -----
> Fight back spam! Download the Blue Frog.
> http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux