Solution 1 :
This depends entirely on the file. A File Structure should be according to a required format that the operating system can understand.
A file has a certain defined structure according to its type like
A text file is a sequence of characters organized into lines.
A source file is a sequence of procedures and functions.
An object file is a sequence of bytes organized into blocks that are understandable by the machine.
When operating system defines different file structures, it also contains the code to support these file structure. Unix, MS-DOS support minimum number of file structure.
Solution 2 :
This depends on the file system and the OS, the question does not specifiy either.
Problem :
I am eager to know how a file in generally structured. Like for example if I get a file’s data in terms of an array of bytes the first 6-10 bytes denote the type of a file. I wanted to know what are other parts in which a file is divided. Is all the data further the first 6-10 bytes are the data present in the file or are there any other partitions denoting the metadata ?
Thanks a lot in advance for answering.
Comments
Comment posted by here
This depends entirely on the file. Often the first few bytes are a magic number indicating file type, but the rest is format-dependent. For example, you can see ELF’s file header
Comment posted by Henry
In Linux and Windows the most general form of a file is just a sequence of bytes without any internal structure imposed by the OS.
Comment posted by Sarvesh Dalvi
@Henry Then where is the metadata of a file stored ?
Comment posted by Henry
The file data does not have any metadata (as far as the OS is concerned). Things like the file name and access rights are stored in a file system specific way.