Re: Re: file_exists()

From: Date: Sun, 23 Oct 2005 00:26:02 +0000
Subject: Re: Re: file_exists()
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-224482@lists.php.net to get a copy of this message
On Sat, October 22, 2005 7:12 pm, Jonny Bergström wrote: > Good idea yes. But apparantly Windows couldn't do it either. :-( > > function file_exists_windows($path) { > exec('dir ' . $path, $output, $return_status); > return $return_status == 0 ? true : false; // Windows dir will return > 0 when > something was found > } First, I don't think $return_status is what you think it is. $return_status is FALSE if your command is not syntactically valid. It will be TRUE if your command is syntactically valid, but you'll need to LOOK at $output to see if the file is listed or not. > It works with "normal" ascii file names, but other than that it's a > no. > Makes you wonder what the problem is here, maybe exec() not supporting > unicode either. If the filename is funky, you are going to have to do whatever you would do in a DOS prompt to escape it, munge, or otherwise convert it to whatever that version of Windows uses. Inlucding 8.3 on ancient Windows, if PHP runs on that junk. -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#224482) next »