12.1 Files


12.1 Files

At some point most computer users must save data to disk. For example, they may need to record names and addresses in a database so they can later be recalled, or use a word processor to write documents such as letters, poems, and memos. If none of these were saved to disk, then that data would no longer exist once the computer was switched off. So to record data in a permanent way such that it can be loaded again into a computer's memory, users sensibly commit data to disk.

Even users who do not venture into the realms of software development typically understand what it means to save data to a disk, although the process of exactly how this occurs and the idea of file formats may not be clear. But for a programmer, this subject is important.

A file is a document of related information, similar to a binder or a book. Information in a file can be wide and varied. In a typical word processor file, for instance, there is more to the document than the text alone-there is font size, font type, text color, paragraph and spacing details, columns, and lots more. When users save a word processor document, they expect this formatting information to be retained in addition to the text when the document is loaded back at a later time. Programmers therefore need to develop a structure that applies to all documents, such that information can be predictably and systematically loaded back into a program for as many different documents as the user might possibly choose. This structure is called a file format, which is analogous to a data structure, except it applies to information stored on disk rather than in system memory.

Each file has a name, and files are typically contained together in folders or directories in the same way files can be arranged in a drawer or cabinet. Thus, a file name should be unique within its folder so it may be uniquely identified from among other files. Folders are then arranged on the hard disk in a tree structure called a hierarchical structure, which resembles a family tree. You can easily see this at work by clicking My Computer and then accessing the C drive. Folders can contain files, and folders can also contain other folders that in turn can contain more files and folders, and so on. Folders too have names, and folder names must also be unique within their containing folder just as file names must be unique. The purpose of all of this is simply to organize data effectively and allow users to easily find their information.




Introduction to Game Programming with C++
Introduction to Game Programming with C++ (Wordware Game Developers Library)
ISBN: 1598220322
EAN: 2147483647
Year: 2007
Pages: 225
Authors: Alan Thorn

Similar book on Amazon
Beginning C++ Through Game Programming
Beginning C++ Through Game Programming
Beginning Game Programming
Beginning Game Programming
The Ultimate Guide to Video Game Writing and Design
The Ultimate Guide to Video Game Writing and Design

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net