Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Strange File Opening Artifact
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
keyboardwalker




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Zren




PostPosted: 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.
keyboardwalker




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: