Page 300 - DCAP404 _Object Oriented Programming
P. 300
Unit 13: Working with Files
Deep space science exploration craft, like Voyager I & II used digital tape based special file Notes
systems. Most modern space exploration craft like Cassini-Huygens used Real-time
operating system file systems or RTOS influenced file systems. The Mars Rovers are one
such example of an RTOS file system, important in this case because they are implemented
in flash memory.
7. Flat file systems: In a flat file system, there are no subdirectories-everything is stored at
the same (root) level on the media, be it a hard disk, floppy disk, etc. While simple, this
system rapidly becomes inefficient as the number of files grows, and makes it difficult for
users to organise data into related groups. Like many small systems before it, the original
Apple Macintosh featured a flat file system, called Macintosh File System. Its version of
Mac OS was unusual in that the file management software (Macintosh Finder) created the
illusion of a partially hierarchical filing system on top of MFS. This structure meant that
every file on a disk had to have a unique name, even if it appeared to be in a separate
folder. MFS was quickly replaced with Hierarchical File System, which supported real
directories.
13.6.2 File Systems and Operating Systems
Most operating systems provide a file system, as a file system is an integral part of any modern
operating system. Early microcomputer operating systems’ only real task was file
management - a fact reflected in their names. Some early operating systems had a separate
component for handling file systems which was called a disk operating system. On some
microcomputers, the disk operating system was loaded separately from the rest of the operating
system. On early operating systems, there was usually support for only one, native, unnamed
file system; for example, CP/M supports only its own file system, which might be called “CP/
M file system” if needed, but which didn’t bear any official name at all.
Because of this, there needs to be an interface provided by the operating system software between
the user and the file system. This interface can be textual (such as provided by a command line
interface, such as the Unix shell, or OpenVMS DCL) or graphical (such as provided by a graphical
user interface, such as file browsers).
!
Caution If graphical, the metaphor of the folder, containing documents, other files, and
nested folders is often used.
13.6.3 Binary Files
In binary files, to input and output data with the extraction and insertion operators (<< and >>)
and functions likegetline is not efficient, since we do not need to format any data, and data may
not use the separation codes used by text files to separate elements (like space, newline, etc...).
File streams include two member functions specifically designed to input and output binary
data sequentially: write and read. The first one (write) is a member function of ostream inherited
by ofstream. And read is a member function of istream that is inherited by ifstream. Objects of
class fstream have both members. Their prototypes are:
write ( memory_block, size );
read ( memory_block, size );
Where memory_block is of type “pointer to char” (char*), and represents the address of an array
of bytes where the read data elements are stored or from where the data elements to be written
LOVELY PROFESSIONAL UNIVERSITY 293