< Previous  |  Contents  |  Next >

3 : Files and Directories        
     

   

DOS Plus Directories

DOS Plus uses a hierarchical filing system similar to the one used by the BBC Advanced Disc Filing System (ADFS). Unlike ADFS no special command is needed when a new disc is loaded because DOS Plus always checks the disc on each access, so there is no need for an equivalent of *MOUNT. To change from one default drive to another you only need to enter the drive name followed by a colon. If the current drive is A and you wish to select drive B as the default drive, your entry would be simply B: as shown in the sequence below, and the drive will change.

A>B:
B>

Drive names can also be part of any command line entry, so to access a file on any disc it is not necessary for that disc to be the current drive.

Arranging Files

You will probably have noticed that many of the files on your discs are arranged into groups of like files. These directory structures will be familar to ADFS users.

Arranging your files neatly in this way is vital if you want to operate efficiently. At home or in the office, you group your files into separate, but distinct, areas, ie electricity, gas, bank, tax and so forth, so that you instantly know where to find them.

For the same reasons it makes good sense to group your personal and program files together so that they are readily available to you. Before we go further on the laying out of these directories, let's examine the way in which the DOS Plus directory structure works in more detail. It's well worth learning as you will reap the benefits in the long run.

Directories

DOS (Disc Operating System) files are organised into directories, as we have already said. However, directories themselves may also contain directories. These sub-directories, as they are called, may also contain more directories and so on, all the way 'down' until the very last item is the file itself. Now if you are working in one directory you can only get at the files that are held in your currently selected directory, or those located in directories below you, that is, directories which have their origin in the current directory.

Suppose, at the point where this string of directories start, we had created another directory – which itself contained other directories, sub-directories and files – we would effectively have two different directory paths. If we are some of the way down one directory path, there is no way we can access files in the other directory path without going back via the start directory – that is, the point where they split. Now if we have several of these directory paths we get a structure like that illustrated in figure 3.1. Turn it upside down and you have a tree structure and that is often how this hierarchical type of filing system is referred to.

 
Figure 3.1 – The Tree structure.

Creating Directories

Obviously directories do not just appear on your disc, it is up to you, as the user, to create them. For the purposes of this book and so that you can practice, take a new disc and format it if it is not already formatted – if you do not know how to go about formatting a disc then see page 14 of Part Two of the Acorn Master 512 Guide. If you have a hard disc then you are okay, as this has a great deal of space which we can use.

The DOS Plus command to create a directory is MKDIR (short for MaKe Directory), and as the book contains 'examples' that is the directory name we shall use. So to create the directory called Examples type:

MD Examples

and press the ENTER key. To ensure that the directory is there, type:

DIR

after the prompt (MD is a short form of MKDIR). If you are using a floppy disc the response on screen should be a little like this:

Volume in drive A is Master 512
Directory of A:\

EXAMPLES   <DIR> 10-12-89                18.12
              1 File(s)    530432   bytes free

System files exist

If you have created it on a hard disc the directory will be present with many others!

The directory can be seen clearly and is marked as such, along with the date and time it was created (obviously these will be different for you!), the number of files on the disc and the space remaining. Note that, although we used upper and lower case letters when the directory was created, and there is no problem is using lower case, DOS Plus has changed the letters to all upper case (capital letters) – in fact DOS Plus cannot tell the difference and only sees characters as upper case.

Creating sub-directories – directories within directories – is just as easy. Enter the directory using the CHDIR (or CD for short) command and then MD. As an example, suppose we wish to create a sub-directory in EXAMPLES called MOON, proceed as follows. First move into the EXAMPLES directory with:

CD EXAMPLES

and make the new directory:

MD MOON

Now catalogue the disc with DIR and you should see something like this:

Volume in drive A is Master 512
Directory of A:\

.               <DIR> 10-12-89          18.12
..              <DIR> 10-12-89          18.12
MOON            <DIR> 10-12-89          18.17
              1 File(s)    528384  bytes free

System files exist

The MOON directory is visible along with two others called . and .. These two have special meanings – "." is the current directory, and ".." is the 'parent' of the current directory. If you're not sure what a parent is, look again at Figure 3.1 – UTILS is the parent of TOOLS, and \ is the parent of UTILS.

The CD command used above changes the current directory. To move up to the root directory, simply enter:

CD ..

and press ENTER.

(The CD .. command means 'go up one level', so if the current directory was \UTILS\TOOLS, then CD .. would make \UTILS the current directory. CD \ will always directly select the root directory.)

All directories on the disc belong to, or are contained within the root directory. This does not have a name, but is designated by a back-slash character (\). This is equivalent to the $ root directory in ADFS. The \ character is also used as the delimiter between directories, in the place where the full stop is used in ADFS.

Note that all directory specifications are within, or subordinate to, the currently-selected directory unless explicitly stated to the contrary. In other words if you wish to refer to a file or directory which 'belongs' to the current directory, your start-point in the structure is assumed to be the current directory by default, no matter how many 'levels' you have descended.

However, if you wish to refer to a file on a completely different branch of the structure without changing the currently-selected directory, your name specification must start from the last common point in the tree. If this is the root directory you must use the initial \ to indicate this. For example:

\dir1\dir2\dir3

specifies the directory dir3 no matter what the current directory is. (The ADFS equivalent would be $.dir1.dir2.dir3.)

Dir1\dir2\dir3 specifies the directory marked * if the current directory is the root (\). It will also specify the directory marked ** if the current directory is dir0. The ADFS equivalent is dir1.dir2.dir3. <There appears to be a diagram missing in the book here - YP>

At this stage a number of commands are worthy of comment, and can be directly compared with their ADFS equivalent for illustration:

      DOS Plus            ADFS Equivalent
  CHDIR – Change Directory   DIR – (change) Directory
  MKDIR – Make Directory   CDIR – Create Directory

When using these commands, the following have special meaning:

      DOS Plus           ADFS Equivalent
  . the current directory  
@
  ..          the current directory's parent  
^
  \ the root directory  
$
  \ directory name delimiter  
.

Filename Syntax

Filenames are very important. When used correctly, you'll easily find your files. Badly selected filenames could mean you'll lose important work or data. The most common filename format consists of a drive identifier, a filename, and filename extension:

{<d:>}<filename>{<.ext>}

The meanings of the symbols are as follows.

{<d:}       is the drive name, This is only necessary if the file is on another drive, but it may be supplied anyway.
     
<filename>   is the first part of the filename, which must always exist. It can be from one to eight characters in length.
     
{<.ext>}   is an optional extension to the name, and can be up to three characters long.

For example, assuming A as the current drive:

SORTFILE            is a file on drive A: with no extension
PROG.EXE   is a file on drive A: with an EXE extension
B:TEXT.DOC   is a file on drive B: with a DOC extension

Filenames, extensions or directory names, can include any characters selected from the following:

0-9
A-z
` $ % & ' () - @ _ ~

You should use the non-alphanumeric characters with caution, especially if you are likely to want to transfer files to either DFS or ADFS, as you will note that DOS Plus allows, for example $. This is an illegal character if transferred to native BBC filing systems. Although the name can be changed during transfer, these characters are unlikely to improve the readability of any filename, and hence are generally best avoided.

Directory names can be the same length as filenames, and in both cases if fewer than eight characters are used, the name is padded with blank spaces. This will be apparent when you display the name by using a 'DIR' command, or a command like 'COPY' or 'FSET', both of which echo their actions, and the names involved, to the screen.

Although the names on disc are physically padded with spaces, and these commands do not remove the spaces from the display (so that all names and extensions line up), under no circumstances should you enter spaces when you enter any filename in any command. Doing so may cause damage to files. See the notes accompanying 'COPY' in Chapter Six for the reasons.

Wildcards may be used with certain operations to reduce typing when commands are to operate on a group of related files. Two wildcards are supported, these are:

*     which can be used to replace the remainder of the field in either a name or an extension
     
?   which can replace any single character in the position used.

In addition, under certain circumstances, the powerful defaults available in DOS Plus commands can be used to further reduce effort. If the command requires a source and a destination filename, it is not necessary to retype the name for the destination file if it is not to be changed. The minimum destination specification can be as little as just the drive name.

For example:

copy text*.txt b:

would copy any file from the current drive to drive B, which has text as the first four characters of its name and any other four characters up to the extension, including spaces, provided that the extension was '.txt'.

copy text?.TXT b:

would copy any file from the current drive to drive B, which has text as the first four characters of its name, any other single character as the fifth, but only spaces in positions six, seven and eight. Again the extension must be .txt.

copy text.* b:

would copy any file from the current drive to drive B, which has text as the first four characters of its name, and only spaces in positions five, six, seven and eight. The extension may be any allowable combination.

Paths

The full statement of a file specification may include a list of directory names, as noted in the discussion of the tree structure earlier. Wherever filenames are supplied as parameters to commands it is always acceptable, even if not always necessary, to supply the full path name.

<filespec> = {<d:>}{<path\>.....}filename{<.ext>}

For example:

C:\dir1\dir2\prog.exe

Strictly speaking, the pathname is C:\dir1\dir2\ in this case, and the filename identifies only the file within the path. DOS Plus provides a command called PATH, which can be used either to set a path semipermanently, or, if called without parameters, will report the current path setting. It should be noted that the current path need not lead to the current directory, nor even to the current drive.

PATH sets up a default directory specification, which DOS Plus will use whenever a command is issued which involves a file not found within the current directory. If the named file is not in the directory set by PATH, then an error results. If the file is found in the specified path, that file will be used as if it were in the current directory.

PATH can be regarded as analogous to the *LIB command in ADFS.

File Types

The filename extension can be used to group together particular types of file. It is largely up to the user how to take advantage of the filename extension. However, DOS Plus uses certain extensions for special purposes:

.CMD       CP/M command file
.COM   MS-DOS command file
.EXE   MS-DOS executable program file
.BAT   Batch file consisting of DOS Plus commands

Each of these extensions tell DOS Plus that the file can be executed. Just type the filename at the command prompt, eg:

A>PIP.CMD

or more normally:

A>PIP

If the extension is not specified, DOS Plus looks for a file using one of the special extensions (in the order shown in the table) then executes that file if it is found. If there is more than one file with the same name and an extension, only the first is executed. Another extension with a special meaning is:

.SYS     This extension is used for special system files

The four discs supplied with the 512 contain other 'standard' filename extensions. They only have a special meaning within the particular application program which uses them. There is no fundamental restriction on using a similar extension for other purposes. However, the application usually groups files together using the extension so it can distinguish between files for the user's benefit.

For example, in GEM Paint, the file extension .IMG is used to denote an image file. When a new image is loaded the program offers a menu of all .IMG files for the user to choose from. If a file is not an image file, but is named .IMG it will appear on the menu. This requires the user to know that such files should not be loaded as an image. Clearly, it is better to choose more appropriate file extensions to avoid problems like these.

Some other 'standard' or accepted conventions for file extensions are shown below in table 3.1. None are in themselves significant to DOS Plus, but may be to other 'standard' software, for example the '.HLP' extension. You should relate their suitability for your files to the applications packages or programs with which they may be used, and any other specific extensions used by your software (eg Supercalc uses '.CAL' and '.XQT').

      Ext                     Signifies
  .HLP   Usually relates to an application's help text file
  .DOC   Usually a wordprocessor document
  .TXT   Usually a ASCII document (you can TYPE it)
  .BAK   Usually a backup file (eg the back-up of textfile.doc would be called textfile.bak)
  .DEF or
.CFG
  Usually an application parameter definition file
  .WRK   Usually an application's work file. Caution, if such a file exists it may be overwritten entirely at the discretion of the application.
       
 
Table 3.1. Common DOS Plus extensions in use.

Devices

The keyboard, screen and printer are all devices which allow input or output to or from the computer. These physical devices may be mapped to logical device names so that they can be specified for use in commands in place of filenames.

For example, a file may be copied from disc to screen, keyboard to disc, or any other combination, just as if it were being copied from disc to disc. For example:

COPY text.doc CON:

Copies the file called TEXT.DOC to the device called CON: which is by default the screen in this case.

The standard device assignments are listed in table 3.2 below:

      Device Name          Device Type          Physical Device
  CON:   Console I/O   Keyboard or screen
  CONIN:   Console input   Keyboard
  CONOUT:   Console output   Screen
  AUX:   Auxiliary I/O   Serial in or out
  AUXIN:   Auxiliary input   Serial port
  AUXOUT:   Auxiliary output   Serial port
  PRN:   List output   Parallel Printer
           
 
Table 3.2. Standard device assignments.

The device assignments can be changed with the DEVICE command explained in Chapter Seven.

Attributes

Each disc file has a number of attributes. Attributes are status flags which allow, or disallow, certain things to happen to a file:

RO    Marks a file as read-only. This prevents overwriting or deleting of the file (except when PIP is used with certain directives, in which case RO can be over-ridden.)
     
RW   Marks a file as read-write. This allows overwriting or deleting.
     
SYS   Marks a file as a system file. This prevents it being shown in a normal directory display.
     
DIR   Marks the file as a directory entry. This points to another area of disc for the directory contents, which may be files or more directories. <This appears to have confused a directory with a non-system file (also called a directory file (because it is normally displayed by the DIR command)). In DOS Plus the DIR attribute is the opposite of SYS – YP>
     
ARCHIVE   Marks the file as having been updated. This is used with the BACKUP command which is used to back up hard disc files. Only files marked as updated are copied by BACKUP. The syntax is ARCHIVE=ON or ARCHIVE=OFF.

Anatomy of a Directory

Being able to read and understand the contents of a disc directory is a fundamental task in computing. Shown below is the beginning and end of the display resulting from issuing two 'DIR' commands with DISC 4 in the drive. The first was a simple 'DIR' with no path supplied, the second was 'DIR \DEMOPROG'. Only part of the display from the first command is shown so as not to waste space. The purpose and meaning of each part of the volume or directory information displayed is explained. Each item is numbered ( [1], [2] etc) with an expansion below to expand the points identified.

DIR

     

A>DIR

Volume in drive A is DISK    #4                [1]
Directory of A:\                               [2]

DEMOPROG     <DIR>     25-05-86  21:53         [3]
Z80          <DIR>     25-05-86  21:55
GEMSETUP APP    33280  25-05-86  21:56         [4]
GEMSETUP RSC    18432  25-05-86  21:57
ACORNBW  SYS    55808  25-05-86  21:57

                     (More files here)

[5]      [6]     [7]      [8]      [9]
EPSHTR36 FNT    54400  25-05-86  22:03
EPSHSS07 FNT     2688  25-05-86  22:04
GEMSETUP TXT    12544  25-05-86  23:49
       38 File(s)      8192 bytes free        [10]

DIR \DEMOPROG

     

A>DIR \DEMOPROG <Line misplaced in printed book - YP>

Volume in drive A is DISK    #4
Directory of A:\DEMOPROG                      [11]

.            <DIR>     25-05-86  21:53        [12]
..           <DIR>     25-05-86  21:53        [13]
SIREN    A86     4096  25-05-86  21:55        [14]
SIREN    EXE     2560  25-05-86  21:55
        4 File(s)      8192 bytes free        [15]
                                              [16]

   
[1]       Shows the label of the volume as set by the LABEL command. This is up to 11 characters long, and is documentary only (ie for your use). It is directly comparable to the title on BBC filing systems.
   
[2]   Shows the current directory name or the name specified with the DIR command. In this case the 'A:\' shows this is the root directory.
   
[3]   Is an entry for a directory called 'DEMOPROG'. This directory is subordinate to the current directory. All directory entries in the current directory are shown as <DIR> to distinguish them from file entries.
   
[4]   Is an entry for a file contained in the current directory.
   
[5]   Is the first part of the filename, which may be up to eight characters long. If the name is less than eight characters the display is padded with spaces as for example both 'SIREN' files shown above. Padding the names allows all the file extensions to line up. When you enter filenames for any command, you should not enter spaces, even if they are shown by this or any other display.

   
[6]   Is the file extension, which may be up to three characters long. Files do not necessarily have to have an extension, although some, like '.CMD or '.EXE' are significant to DOS Plus, and should not be used for general purposes. When full filenames are entered a dot (.) is used to indicate where the first part of the name ends and the extension begins. Spaces should never be entered. For example to enter the first 'SIREN' name in a command it should be entered as 'SIREN.A86' at the appropriate point.
   
[7]   This is the total file length in bytes. Note that this is not necessarily the exact space occupied by the file. File space is allocated in minimum sized units, for example 1024 bytes for 800k format, therefore even a 20 byte file will use a minimum of 1k bytes of disc space.
   
[8]   This is the date (as held in the DOS clock) of the last update written to this file. Note that if the file is copied to another disc the date is taken with it, it is not revised to the date the copy was carried out.
   
[9]   This shows the time as held in DOS's clock of the last time this file was written to. All the comments for [8] above apply.
   
[10]   This is always the last line of a 'DIR' display, and shows the total number of objects (files plus directories) listed in the output. The bytes free value refers to the entire disc, as space is not pre-allocated or reserved, but simply used, as needed, by anything on the disc. The only way to 'reserve' disc space is by creating a dummy file of the required size.
   
[11]   Is the directory name. For any directory subordinate to the root directory the full path is shown, in order, from the root to the current directory inclusive, with '\' separating the entries if necessary.
   
[12]   This is the entry for the current directory.
   
[13]   Shows the parent directory immediately above the current directory. In this case the parent is the root directory.
   
[14]   Shows a file within the current directory. Details as for [5] to [9].
   
[15]   Shows the summary of objects displayed within the current directory. Note that the free space is the same as is shown in [10], because, as noted, it applies to the whole disc.
   
[16]   In this case this line is empty, showing that the DOS Plus system is not resident on this volume. If for contrast you issue a 'DIR' with the system disc in the drive this line will contain the message "System files exist" showing that the system files (those with a '.SYS' extension) are present.

< Previous  |  Contents  |  Next >

About the Master 512 | Bibliography