Computer Science Canada

Strange File Opening Artifact

Author:  keyboardwalker [ Tue Oct 22, 2013 2:31 pm ]
Post subject:  Strange File Opening Artifact

I found a strange happening when using the open command, and I want to know about it

Basically, if you use "aux" as your filename when using 'open' to open a file, it will always give proper stream number, as if a file was opened, even though no such file exists. Also, nothing can be written to or read from it.
Also of note; case doesn't affect anything, and any file extension or none at all will still be accepted, and the same thing happens with "nul" (although that seems a bit more reasonable).

I'm simply curious about why this is, and/or what use there is to it.

Turing:


var FileStream : int

open:FileStream "aux", get



Turing 4.0.5

Author:  Zren [ Tue Oct 22, 2013 6:17 pm ]
Post subject:  RE:Strange File Opening Artifact

Interesting.

It looks like those are reserved filenames designated by Windows.

Note: Found by googling aux nul open file.

code:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx


Quote:
Do not use the following reserved 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 immediately by an extension; for example, NUL.txt is not recommended. For more information, see Namespaces.

Author:  keyboardwalker [ Wed Oct 23, 2013 8:21 am ]
Post subject:  Re: Strange File Opening Artifact

Thanks, that does seem to be the cause. Interestingly, Turing 4.1.1 doesn't do this; if you try to open 'aux' or 'nul' with get permission, the filestream will be -10, and if you do it with 'put' permissions it will create a file with that name in it's directory, which Windows won't let you access.


: