mIRC Home    About    Download    Register    News    Help

Print Thread
$exists() return $false for some filename #169099 19/01/07 09:06 AM
Joined: Nov 2006
Posts: 4
A
Axis Offline OP
Self-satisified door
OP Offline
Self-satisified door
A
Joined: Nov 2006
Posts: 4
Hello..
i found bug when using $exists in mirc 6.21. The filename like
"ip.txt" , "ip.html", "ip.dll" return $false even that the file exists in mirc folder. eek eek

Re: $exists() return $false for some filename [Re: Axis] #169102 19/01/07 09:41 AM
Joined: Aug 2004
Posts: 16
S
Smay Offline
Pikka bird
Offline
Pikka bird
S
Joined: Aug 2004
Posts: 16
Confirmed on my machine. Same goes for $isfile().

If you want a hacky workaround, you can use the $file command, e.g.:
Code:
if ($file(ip.txt).size == $null) {
  echo File doesn't exist
}



Smay!
Re: $exists() return $false for some filename [Re: Axis] #169113 19/01/07 02:08 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
I don't know the reasoning behind this, but I'm sure it was intentional. You also cannot /write ip.txt test and perhaps other commands as well. You can always just use somthing other than ip.txt as a filename.


Invision Support
#Invision on irc.irchighway.net
Re: $exists() return $false for some filename [Re: Axis] #169115 19/01/07 04:10 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
This is related to Windows/DOS device names. In DOS there are devices named CON, AUX, COM[1-9], LPT[1-9], PRN, and NUL which prevents any filename in DOS or Windows having a file with those names (with or without any file extension).

It's been suggested in the past by Khaled that this is also true for ip, global, shadow - and certainly mIRC does treat those filenames the same way (which is the reason for your bug). However I can't find any documentation explaining why those three additional files are reserved and I can't find any other application that prevents their use. Maybe Khaled or someone else can provide a link to where this is documented?


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: $exists() return $false for some filename [Re: starbucks_mafia] #169117 19/01/07 04:31 PM
Joined: Apr 2004
Posts: 840
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 840
Basically mIRC uses a Windows API call to check if a filename is a DOS device; if so, it will not allow access to that file. That Windows API call is not actually meant to be used this way though, as it also returns device names that cannot be used like filenames in the way that CON, NUL etc can. As it happens, those "ip", "global", "shadow" names are such device names used by Windows. You can get the full list (which differs from system to system) with this utility.


Saturn, QuakeNet staff
Re: $exists() return $false for some filename [Re: Sat] #169120 19/01/07 05:30 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Ah, thanks. I spent an age trying to find something linking those words to device names. There's so much crap in MS's Win32 API documentation I couldn't find anything useful just searching through MSDN.

As you say, they're not the same as the "universal" device names NUL, CON, etc. so mIRC shouldn't really be checking for them. Seems like a bug that's overdue to be fixed...


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: $exists() return $false for some filename [Re: Sat] #169209 20/01/07 10:10 AM
Joined: Dec 2002
Posts: 36
T
TC_Hessen Offline
Ameglian cow
Offline
Ameglian cow
T
Joined: Dec 2002
Posts: 36
Hi,

yes, but there must be a different. I have devices Names such as "Ip" and "TrueCrypt", but it's possible to access any file like "Ip.txt" or just "Ip".

Writing a a file "con.txt" raises an error. So, "Ip" may be be a device name, but it is accessable as a normal file using the command line or the explorer. I am not sure what mirc is doing, but it is not transparent for the user and I would call it a bug.


cu

TC / Mario
Re: $exists() return $false for some filename [Re: TC_Hessen] #169385 22/01/07 02:02 PM
Joined: Dec 2002
Posts: 4,521
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,521
mIRC asks Windows whether the file name in question is a device name or not. If Windows says that it is a device, mIRC will prevent access to it. There's nothing more to it than that :-)

Re: $exists() return $false for some filename [Re: Khaled] #169389 22/01/07 02:46 PM
Joined: Apr 2004
Posts: 840
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 840
The point was that not (by far) all device names are actually recognized as device names by Windows' file operations, and therefore the file names that happen to be device names are blocked unnecessarily.

The fact that Windows says that a name is a device, doesn't automatically mean that the name can't also be used as normal filename.


Saturn, QuakeNet staff