Friday, July 27, 2007

Caught in a rat trap

Now, lately I have been working on a project that involves image processing. For the last couple of hours my program has been causing my PC speaker to beep when I tried to dump an image to a file "con.bmp". Furthermore symbols started to appear on my command line for no reason it seems. Extremely frustrated at the lack of progress I finally decided to post it as a question on a developer forum.

The reply I got from a kind expert was kind shocking. There was nothing wrong with my program. I was totally smacked by M$'s WinXP. Turns out that WinXP does not allow files to be called "con" with any extension for that matter (e.g. "con.bmp"). These files are reserved device files. Unlike Linux where the device files are kept in a special place, in WinXP, they can be accessed everywhere (that is why they have to be reserved)! What is worse is that "con" and its extensions are not the only reserved file names.

"Do not use the following reserved device names for the name of a file: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed by an extension, for example, NUL.tx7.

Windows NT: CLOCK$ is also a reserved device name."
-- msdn

No comments: