mIRC Home    About    Download    Register    News    Help

Print Thread
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

Joined: Aug 2004
Posts: 16
S
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!
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
Joined: Dec 2002
Posts: 2,962
S
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.
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
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
Joined: Dec 2002
Posts: 2,962
S
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.
Joined: Dec 2002
Posts: 36
T
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
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
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 :-)

Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
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

Link Copied to Clipboard