Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 21-Sep-11 11:14am
Edited 21-Sep-11 17:31pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
SAKryukov at 21-Sep-11 17:38pm
   
Correct, my 5.
--SA
David W. Young at 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 at 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)



Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 21 Sep 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100