Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello, I have a quick question concerning file attributes. I am only talking about general file attributes such as read only, etc. More to the point, are these attributes stored within the file itself, and if so, what is the format that they are stored in? Personally, I'm thinking that they are somehow mapped within the operating system itself as opposed to the file, but I just want to be sure.

I also have another question, what is the termination sequence or character for a general binary/text file? In Layman's terms, what marks the end of a file? Thanks for the help. Regards.

Edit: By binary file, I mean a file that stores unique data structures.
Posted
Updated 21-Sep-11 16:31pm
v2

1 solution

The read-only attribute and similar attributes are part of the meta-data for the file. They are stored by the operating system and cannot be found in the file data.

Text files don't typically actually have an end of file character (or sequence) stored in the data. You know where the end of the file is by the number of bytes read. There is an end of file ASCII character that can be used, but typically should not be treated as the end of the file. Some libraries will also return a special constant (EOF) that indicates the end of a file.

Also, there is no such thing as a general binary file that has a specific interpretation (such as an end of file character). All files are binary files, including text files.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 21-Sep-11 17:38pm    
Correct, my 5.
--SA
David W. Young 21-Sep-11 22:27pm    
Sorry, I had poorly phrased that, by binary file I meant a file used to store custom data structures and the like. Thanks for helping a newbie like me!
Edit: I meant to respond to the guy above you. Sorry about that.
krmed 22-Sep-11 8:22am    
In the old "DOS" days, a Ctrl-Z marked the end of file (usually). However in today's world, there is normally no such thing as an end of file mark - either text or binary. The file only contains whatever the creator decided.

If you write a data structure from your software, you should know the format, and therefore know how much to read from the file. If you choose to use some kind of EOF indicator in files you create, you need to be aware that that "character" or "sequence" cannot appear anywhere else in the file, so you have to handle that. This is why most files don't contain any such mark.

Hope it helps.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900