Chapter 4

Files and Directories

Before you can use OS-9 extensively, you need to know how the system organizes and stores data on disk. The information in this section is true for both floppy diskettes and hard disks. However, because of the greater storage capacity of a hard disk, it is of particular importance to hard disk users.


About Files

Consider the information stored on disks to be of two basic types, programs and data. A program is code that causes your computer to execute a task. Data is information that a program uses or that a program creates.


All the information that OS-9 stores on disks, whether program or data, is stored in units called files. Whenever a program creates a file, OS-9 defines a portion of your disk to store it. It keeps the location of the file in a special list (called a directory), also located on the disk, so that it knows where to find your program or data the next time you want it.


About Directories

A directory is a storage space for filenames, other directory names, or both.


After you format a disk, it contains ~ one directory called the ROOT directory. However, a disk can have many directories. For instance, besides the ROOT directory, your System Master diskette contains the CMDS and SYS directories. The ROOT and CMDS directories are especially important to you.


When you boot OS-9, you automatically begin operation from these two directories. The ROOT directory becomes your current data directory and the CMDS directory becomes your current execution directory.


Whenever you ask OS-9 to store a file on a diskette, it automatically stores it in the current data directory (the ROOT directory), unless you tell it otherwise. If you ask OS-9 to execute a command or program, it automatically looks for that command or program in the execution directory (the CMDS directory), unless you tell it otherwise.

Getting Started With OS-9

Every OS-9 directory can also contain other directories, called subdirectories. For instance, SYS, and CMDS are established as subdirectories of the ROOT directory. Put in chart form, your ROOT directory with its subdirectories looks like this:







But there are also files in the ROOT directory, OS9Boot and Startup are two. The full ROOT directory might look like this:



OS9Boot

Startup






You can create another subdirectory of the ROOT directory if you want. Fbr instance, if you created a directory named FAMILY, the chart of the ROOT directory looks like this:



OS9Boot

Startup






4-2
Files and Directories / 4

After you create the FAMILY directory, you can also create other directories in it. Suppose you create two subdirectories named PLEASURE and WORK. The chart organization is as follows:

ROOT DIRECTORY

OS9Boot
Startup



PLEASURE WORK

Figure 4.4

The directories you create also can hold files. If you created three files each in the PLEASURE and WORK directories, the chart might look like this:

ROOT DIRECTORY

OS9Boot

Startup


CMDS




PLEASURE WORK

y

mom

dad

joe


mom dad joe



You can continue to create files and subdirectories in any or all of your disk's directories until you fill the disk's storage space.

4-3
Getting Started With OS-9

Multiple Directories

There is nothing wrong with storing all your files in the ROOT directory. Doing so makes it easy to access them because they are always in your data directory.


However, creating multiple directories makes it easy to keep your data organized when you have many files, or if more than one person is using the same disk. Such a multiple-directory organization is especially helpful when using hard disks, which can store hundreds of individual files.


Also, when you have multiple directories, you can store files having the same name in different directories without conflict, such as in the PLEASURE and the WORK directories of Figure 4.5.


About File and Directory Names

The file and directory names shown so far consist only of letters of the alphabet, but you can use other characters and symbols in a file or directory name as long as each name begins with a letter. The following is a complete list of acceptable characters:










You can include as many as 29 characters in a file or directory name.


Examples of Filenames

The following are samples of filenames that OS-9 can recognize:








4-4
Files and Directories / 4

Examples of invalid filenames are:

his*hers ..

.DATA ........

COST + INT . . .

100-dollar-gifts

About Pathlists

.because * is not a valid character for names . because the name does not begin with a letter .because + is not a valid character for names . because names cannot begin with a digit

Because you can organize OS-9 disks into multiple levels, you need a way to tell the system where to find directories and files. The directions you give are called pathlists.


A pathlist is exactly what its name implies-a path (or route) to the device, directory, or file you want to access. For instance, if you are in the ROOT directory (see Figure 4.5) and want to look at the contents of a file in the WORK directory, you must tell OS-9 how to get there. The pathlist from the ROOT directory to the Dad file is f a m i 1 y / w o r k / d a d . OS-9 expects you to separate the junctions of pathlists with slashes. To look at the contents of Dad, you type:


list family/work/dad

Because you are accessing a file on the current disk, you do not need to specify a drive name. Because every disk contains a ROOT directory, and all other directories and files branch from it, ROOT is always implied in a pathlist. If Figure 4.5 represented the diskette in Drive /D 1, the pathname to the Dad file would be /dl/family/work/dad.


Depending on the location of the directory or file you want to access, a full pathlist need not contain any more than the name of a drive, the name of a directory, or the name of a file. For instance, the complete pathlist from the ROOT directory of Figure 4.5 to the Startup file is 5 t a r t u p . To look at the contents of Startup, type:


list startup

4-5
Getting Started With OS-9

Anonymous Directory Names

To save time, or if you do not know a full pathlist, you can refer to the current directory, or to a higher-level directory, using an anonymous name, or name substitute, as follows:






You can use an anonymous directory name in place of a pathlist or as the first name in a pathlist. Some examples are:





Anonymous names can refer to either execution or data directories, depending on the context in which you use them.


About Device Names

In the same manner that OS-9 has names for its commands, it also has names for its devices. These names are abbreviations of actual device names. Fbr instance, instead of typing Disk Drive 0 to refer to your first disk drive, you only need to type / DO. To refer to your printer, type / P . OS-9 windows are named /W through /W 7 .


All of OS-9's device names are preceded by a slash this is how OS-9 can tell you are referring to a device rather than a directory or file. When you purchase your System ester diskette, OS9 is configured to recognize two disk drives, a printer, and one terminal port. Fbr information on how to configure your system to recognize other devices, see Chapter 7.


4-6