mIRC Home    About    Download    Register    News    Help

Topic Options
#169099 - 19/01/07 09:06 AM $exists() return $false for some filename
Axis Offline
Self-satisified door

Registered: 03/11/06
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

Top
#169102 - 19/01/07 09:41 AM Re: $exists() return $false for some filename [Re: Axis]
Smay Offline
Pikka bird

Registered: 07/08/04
Posts: 16
Loc: Illinois
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!

Top
#169113 - 19/01/07 02:08 PM Re: $exists() return $false for some filename [Re: Axis]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top
#169115 - 19/01/07 04:10 PM Re: $exists() return $false for some filename [Re: Axis]
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
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.

Top
#169117 - 19/01/07 04:31 PM Re: $exists() return $false for some filename [Re: starbucks_mafia]
Sat Offline
Hoopy frood

Registered: 19/04/04
Posts: 838
Loc: The Netherlands
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

Top
#169120 - 19/01/07 05:30 PM Re: $exists() return $false for some filename [Re: Sat]
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
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.

Top
#169209 - 20/01/07 10:10 AM Re: $exists() return $false for some filename [Re: Sat]
TC_Hessen Offline
Ameglian cow

Registered: 23/12/02
Posts: 36
Loc: Germany, Frankfurt/Main
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

Top
#169385 - 22/01/07 02:02 PM Re: $exists() return $false for some filename [Re: TC_Hessen]
Khaled Offline


Planetary brain

Registered: 04/12/02
Posts: 4420
Loc: London, UK
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 :-)

Top
#169389 - 22/01/07 02:46 PM Re: $exists() return $false for some filename [Re: Khaled]
Sat Offline
Hoopy frood

Registered: 19/04/04
Posts: 838
Loc: The Netherlands
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

Top