Errors in 0.0.11

Want to share what MODs you've gotten to work with EM? Happy about all the time your're saving? Want to say "thanks"? Here's the place.
Forum rules
DO NOT give out any FTP passwords to anyone! There is no reason to do so! If you need help badly enough, create a temporary FTP account that is restricted to only the files that you need help with and give the information for that. Giving out FTP information can be very dangerous!
Locked
iliasch
Registered User
Posts: 23
Joined: Sun May 11, 2003 3:50 pm
Location: Greece

Re: Errors in 0.0.11

Post by iliasch »

@Ptirhiik_:
I guess you're referring to is_file/is_link/is_dir.

First of all you won't be creating that many directories, so three checks won't make a visible difference. Can you limit that to one check though? Tell me how!

User avatar
Ptirhiik_
Registered User
Posts: 526
Joined: Tue Nov 18, 2003 8:35 am

Re: Errors in 0.0.11

Post by Ptirhiik_ »

You are only looking for a directory or an not existing item, that's all :). If you want to translate this in optimized coding, you will write something like that :

Code: Select all

$exists = file_exists($foo);
if ( $exists && !is_dir($foo) )
{
   // failed
}
else if ( !$exists )
{
   // create
}

iliasch
Registered User
Posts: 23
Joined: Sun May 11, 2003 3:50 pm
Location: Greece

Re: Errors in 0.0.11

Post by iliasch »

What you show does exactly the same, but uses one less call and one more variable. How much difference does it make considering that the script will only be used a few times (how many directories will you create for each mod?)

Besides, if you want an even more optimized code you would use:

Code: Select all

$type = @filetype($foo);
if ( empty($type) )
{
   // create
}
elseif ( $type != 'dir' )
{
   // failed
}
Just one call and a variable used 8)

Anyway, Nuttzy will code it the way he likes it. I'm just glad I managed to make you all understand. Happy coding guyz :)

User avatar
Ptirhiik_
Registered User
Posts: 526
Joined: Tue Nov 18, 2003 8:35 am

Re: Errors in 0.0.11

Post by Ptirhiik_ »

You seems to lack some knowledge about file access issue on different configurations :) : believe me, I didn't this precise command hazardously, nor their. I didn't neither set a var to use with the file_exist() because it looks good :lol:. Really, the code I granted is way better, as it will works on all configurations :). But well, that's not the point, is it ? :)

iliasch
Registered User
Posts: 23
Joined: Sun May 11, 2003 3:50 pm
Location: Greece

Re: Errors in 0.0.11

Post by iliasch »

Ptirhiik_ wrote:You seems to lack some knowledge about file access issue on different configurations :) : believe me, I didn't this precise command hazardously, nor their. I didn't neither set a var to use with the file_exist() because it looks good :lol:. Really, the code I granted is way better, as it will works on all configurations :). But well, that's not the point, is it ? :)
I'm afraid you're true in what you say; I do lack technical knowledge and I've got no problem to admit it. :) Also, I wouldn't hesitate to use php 4.1+ functions, even if some people can't use it (not true in this particular case).

Please tell me though, why doesn't filetype() work on all configurations? And where might I get some more info on possible issues between different filesystems/configurations?

User avatar
Ptirhiik_
Registered User
Posts: 526
Joined: Tue Nov 18, 2003 8:35 am

Re: Errors in 0.0.11

Post by Ptirhiik_ »

Refer to the various php support board, and to the basic documentation. At least, performing numerous tests by yourself and having support to do on large-published script are the best to learn the traps.

iliasch
Registered User
Posts: 23
Joined: Sun May 11, 2003 3:50 pm
Location: Greece

Re: Errors in 0.0.11

Post by iliasch »

Well, I've been searching about access issues lately, because I'm working on the ftp subsystem and have met with such problems. However, either I'm not looking at the right place or there have been no reports about filetype() :) I guess I'll take your word for it and keep looking.

Locked