




                                   UCD v1.10
                                --------------




                              A small utility by

                           Uffe Holst Christiansen.
                          --------------------------




                  Copyright (C) Uffe Holst Christiansen, 1992
                             All rights reserved

                             Freely distributable
                              S H A R E W A R E




Author
------
        Uffe Holst Christiansen
        Kollegiebakken 9, 816
        DK 2800 Lyngby
        Denmark


Special note for Australians
----------------------------
Well, this is not because there is special shareware conditions for Australians
nor because I think Australians are lesser bright people so the need a special
part in the documentation to help them using UCD, but because I will be in Au-
stralia between March 1993 and June/July 1993.

As a part of my study a friend and I will be visiting The University of Queens-
land in Brisbane from March until the middle of June. After our visit at the
university my friend and I intend to travel around in Australia "to experience
the country" as some people like to put it. Since none of us are what you could
call wealthy it would be very nice to know some people somewhere in Australia
who would like to offer a bed and a meal.

And it would of course also be nice to meet some Australians not to say some
Australians who think the Amiga is the best computer ever made.

Our intention is to travel from Brisbane to Alice Spring to Adelaide to Mel-
bourne to Sydney and maybe back to Brisbane again but nothing is certain since
we won't plan anything until we are in Australia.

So if you like to have two young students living for a day or two sometime in
the periode from the middle of June until the end of July/the middle of August
and like to meet some Danes then please don't hesitate to write to the address
above or if its to late then try something like:

	Uffe Holst Christiansen
	Poste Restante
	Head Post Office            You can probably find a better address for
	Brisbane                    the Brisbane Head Post Office yourself :-)

Remember it probably will take a letter at least a week to travel from Austra-
lia to Denmark, and we will be leaving Denmark around February 25th. I'm looking
very much forward to hear from you and hopefully also visiting you.

See you!


Shareware notice
----------------
UCD is shareware and if you use (and hopefully also like it) you have the
moral duty to send me a contribution. The amount I would suggest for a con-
tribution is $10. See later for more information about distribution etc.


Contents at line:
--------
 29 - Author
 37 - Special note for Australians
 75 - Shareware notice
 82 - Contents
116 - UCD - what is it?
129 - Archive UCD.lha contents
141 - How does UCD work?
155 - The format of UCD.dirs
183 - Usage
188 - How to use it
192   - Create directory structure file
222   - Append to directory structure file
249   - Make directory structure file
306   - Installation of directory structure file
326   - Storing directory structure file
344   - Changing directory
377   - Change directory to root directory
385   - Change directory to parent directory
398   - Help
403 - Return codes
410 - Wildcards
435 - Redirection of output
448 - Sample files
463 - Additional notes
518 - Limitations
546 - Future updates
562 - Distribution and copyright
587 - Acknowledgment
612 - Final note
637 - Versions


UCD - what is it?
-----------------
UCD is kind of a CD utility capable of doing something the AmigaDOS CD com-
mand not is able to do. It is - like CD - a CLI only utility.

UCD has the ability to change the current directory to a directory anywhere on
the volume or even on other volumes.

UCD also has the ability of keeping track of the directory structure of more
than one volume at the same time, i.e. you can directly change directory to
another volume without specifying the volume.


Archive UCD.lha contents
------------------------
The LhA archive contains the following files:

        UCD             The executable program. This file is imploded.
        UCD.doc         The documentation file (you're reading it).
        UCD.doc.info    Documentation file icon.
        UCD.dirs        A sample directory structure file containing the
                        directory structure of my pre-harddrive Workbench.
        UCD.make        A sample make file to use with the switch -m or -M.


How does UCD work?
------------------
UCD scans the directory structure and stores it in a file called UCD.dirs,
which it places in a UCD directory in RAM:

UCD the uses this directory structure file to locate a directory to change
to.

If you don't want to do a directory structure scan every time you reboot, UCD
can be instructed to store UCD.dirs in SYS:t (NOTE, it will be located in
SYS:t - not in t:). At reboot UCD can be instructed to install this UCD.dirs
in RAM:UCD for later use.


The format of UCD.dirs
----------------------
When scanning the directory structure UCD builds the directory structure file
UCD.dirs which contains the directory structure information needed by UCD.

An example:

Let us assume we in the volume DH0: have the directory devs containing the
subdirectories keymaps, printers and clipboards:

        devs (dir)
             keymaps (dir)
             printers (dir)
             clipboards (dir)

Using UCD to create the directory structure file produces the following for
devs and its subdirectories:

        devs    DH0:devs
        keymaps DH0:devs/keymaps
        printers        DH0:devs/printers
        clipboards      DH0:devs/clipboards

The actual format is:

        <directory><tab><volume:path/directory><new line>
 

Usage
-----
USAGE: UCD [-<A|a|C|c|d|F|f|h|M|m|s|?>|?] [volume:|dir|file]


How to use it
-------------
Now follows a description of the different possibilities you have with UCD.

-c,-C   Create directory structure file
        -------------------------------
        To create the directory structure file UCD.dirs you use the switch -c
        or -C.

        USAGE: UCD -c volume:

                This will create UCD.dirs for 'volume:'.

        USAGE: UCD -C volume:

                This will create UCD.dirs for 'volume:' and it will in addi-
                tion store UCD.dirs in SYS:t for future use.

        Example: UCD -c dh0:

                This scans the directory structure for dh0: and stores it in
                RAM:UCD/UCD.dirs, it will not be stored in SYS:t.  To do that
                you must use the switch -C.

        Please notice the create switches (-c, -C) will delete an already
        existing UCD.dirs in RAM:UCD. The switch -C also deletes UCD.dirs in
        SYS:t.

        If the volume name contains spaces the volume name must be surrounded
        by quotes, i.e. "Volume 1:".

        NOTICE: The -C switch will change the file stored in SYS:t.


-a,-A   Append to directory structure file
        ----------------------------------
        To append a directory structure to the directory structure file
        UCD.dirs you use the switch -a or -A.

        USAGE: UCD -a volume:

                This appends directory structure information of 'volume:' at
                the end of the UCD.dirs currently located in RAM:UCD.

        USAGE: UCD -A volume:

                This switch will after appending the directory structure in-
                formation of 'volume:' on RAM:UCD/UCD.dirs store the directory
                structure file in SYS:t.

        Example: UCD -A dh1:

                This will scan the directory structure for dh1: and appending
                it to RAM:UCD/UCD.dirs before storing UCD.dirs in SYS:t.

        If the volume name contains spaces the volume name must be surrounded
        by quotes, i.e. "Volume 1:".

        NOTICE: The -A switch will change the file stored in SYS:t.


-m,-M   Make directory structure file
        -----------------------------
        To make a directory structure file UCD.dirs you use the switch -m
        or -M.

        This is actually a combination of creating and appending. If you have
        an harddrive with for example 5 partitions (DH0: through DH4:) you
        normally will have to do the following to make a directory structure
        file containing information of all five partitions:

                UCD -c DH0:
                UCD -a DH1:
                UCD -a DH2:
                UCD -a DH3:
                UCD -A DH4:

        Notice I use the switch -A in stead of -a for the last scan. By using
        the switches this way I only store UCD.dirs in SYS:t once.

        The above process of scanning many partitions is a little bit annoy-
        ing if you often have to rescan the directory structure. It could of
        course be stored as a batch file.

        An easier way is to make a file containing the following information:

                DH0:
                DH1:
                DH2:
                DH3:
                DH4:

        Please notice it is important the file don't contain any additional
        spaces, tabs etc. Only new lines between the entries are accepted.
        We could for example save the file as s:UCD.make.

        Now it is possible to do a scan of all partitions with the command:

                UCD -m s:UCD.make

        USAGE: UCD -m file

                This scans the volumes mentioned in 'file'.

        USAGE: UCD -M file

                This scans the volumes mentioned in 'file', and will after-
                wards store UCD.dirs in SYS:t.
 
        The switches -m and -M will change the UCD.dirs currently located in
        RAM:UCD. The -M switch will in addition change the UCD.dirs in SYS:t.

        If the volume name contains spaces the volume name must be surrounded
        by quotes, i.e. "Volume 1:".

        NOTICE: The -M switch will change the file stored in SYS:t.


-s      Installation of directory structure file
        ----------------------------------------
        If you after a reboot have the directory structure file located in
        SYS:t you install it in RAM:UCD with the switch -s (setup).

        USAGE: UCD -s

                This installs the UCD.dirs located in SYS:t in RAM:UCD. It is
                not possible to use UCD without the directory structure file
                installed in RAM:UCD.

        Please notice that setting up the UCD system using the switch -s will
        delete an already existing UCD.dirs in RAM:t.

        It is possible to reinstall the UCD.dirs directory structure file in
        SYS:t if you want to. That could maybe be necessary if you have ap-
        pended directory structure information of some floppies (using the -a
        switch), and no longer want UCD to take effect of this information.


-d      Storing directory structure file
        --------------------------------
        Have you made a directory structure file without storing it in SYS:t
        and decide you want to do this, it can be done using the switch -d
        (d as in Disk).

        USAGE: UCD -d

                This stores UCD.dirs located in RAM:UCD in SYS:t.

        This is actually the reverse of using the setup switch -s.

        Please notice that this will delete an already existing UCD.dirs in
        SYS:t.

        NOTICE: The -d switch will change the file stored in SYS:t.


-f,-F   Changing directory
        ------------------
        Well, changing the directory is actually the purpose of UCD, so how
        how do you do that?

        USAGE: UCD dir

                This will change the directory to 'dir' if 'dir' can be found
                in the directory structure file UCD.dirs.

        USAGE: UCD -f dir

                This will do the same as 'UCD dir', but the -f switch is
                necessary if the first character in 'dir' is a dash.

        USAGE: UCD -F dir

                This will change the directory to 'dir' if 'dir' can be found
                in the directory structure file. The difference between the
                -F switch and the -f switch is that the -F switch is case sen-
                sitive, i.e. 'UCD -F dir' is not the same as 'UCD -F Dir'. The
                -f switch will treat 'UCD dir' and 'UCD Dir' as the same di-
                rectory to change to.

        Example: UCD include

                This will in my environment change the directory to 'DH3:lc/
                include' whatever the current directory is.

        If the directory name contains spaces the directory name must be sur-
        rounded by quotes, i.e. "Directory 1:".


:       Change directory to root directory
        ----------------------------------
        A colon changes the directory to the root directory on the current
        volume.

        USAGE: UCD :


/,..    Change directory to parent directory
        ------------------------------------
        A slash or two dots (like on PCs again) will change the directory to
        the parent directory of the current directory.

        USAGE: UCD /

        USAGE: UCD ..

        UCD does NOT like CD support // which change directory to the parent
        directory of the parent directory of the current directory (!).


?,-?,-h Help
        ----
        The switches -h, -? or just ? prints a very short help to the screen.


Return codes
------------
Upon success zero is returned. Upon failure one is returned regardless of
type of failure, except the switch -s returns 5 (WARN) upon failure; see the
section with "Additional notes".


Wildcards
---------
From version 1.10 UCD supports wildcards.

The following wildcards are accepted:

?       Represents any single character, i.e. 'Hel?o' could be 'Hello' or
        'Helwo' but not 'Helxxo'.

#?      Represents any number of characters, i.e. Hel#?o could be 'Hello',
        'Helwo' but also 'Helxxo' or 'Helabcdefo'. I have only include this
        wildcard because it is a standard AmigaDOS wildcard.

*       Represents any number of characters, and works exactly like the wild-
        card #?.

Wildcards are only accepted when you change the current directory, i.e. with
no switch or with -f or -F.

Well, there is maybe a little problem with the ? wildcard, because it does not
always behave like I want it to behave when I use something like X?, with the
? as the last character in the pattern, but I think everything else work fine,
so that will have to do for now.


Redirection of output
---------------------
It is possible to use the standard AmigaDOS type for redirection of output to
the screen, the best use for this is to redirect the screen output til NIL:

I.e. UCD >NIL: -s will setup the UCD system and no information will be send
to the screen. 

I would only consider redirection of the output to the screen if some UCD com-
mands are placed in the startup-sequence. It will be too much trouble using it
when you normally use UCD to change directory.


Sample files
------------
Two sample files accompany UCD.

The first file UCD.dirs contain the directory structure of my old workbench
disk. The disk was defragmented and reorganized and the directory scan took
20 seconds and had a memory consumption of 20 k. UCD.dirs was made using 'UCD
-c DF1:'. Depending on the fragmentation of the disk, the number of directo-
ries and the number of files a scan can take much longer.

The second file UCD.make is the file I have placed in s: to do a scan of all
my partitions on my harddrive. I use the command 'UCD -m s:UCD.make' to do
the directory structure scan.

 
Additional notes
----------------
The files UCD.dirs located in RAM:UCD and/or SYS:t is protected from
deletion. The only reason for this is that I always use RAM: for temporary
files and I decided to protect it from deletion so I still can use the syntax
'Delete RAM:#? ALL' to delete "all" files in RAM: including subdirectories
without deleting UCD.dirs.

If you want to edit (or delete) UCD.dirs you therefore have to make it
writable:

        protect UCD.dirs +wd

Now it will be possible to edit UCD.dirs. When you are finish then protect it
again from deletion:

        protect UCD.dirs -wd


I would suggest that you place UCD in c:. If you only have an floppy disk
environment I would suggest you do the following to the startup-sequence:

        MakeDir RAM:c
        Copy c:UCD RAM:c
        Protect RAM:c/UCD -d
        Path RAM:c

This will place UCD in RAM:c and as long as you don't have a 'Path c:' before
the 'Path RAM:c' it will load the UCD located in RAM:c in stead of the one
located in c:. It is of course also possible to copy other files from c: to
RAM:c to speed up you computers performance, i.e. commands like CD, Copy,
Delete, Dir, List, MakeDir, Rename and Type and/or other commands you often
use from the shell.

I would suggest that you include something like the following in you startup-
sequence:

        Mount RAD:
        Dir >NIL: RAD:
        UCD -s
        If WARN
          UCD -m s:UCD.make
          UCD -a RAD:
        Else
          UCD -a RAD:
        EndIf

First I mount the recoverable ram drive and redirect the directory of RAD: to
NIL:. Then I setup the UCD system using the switch -s. If UCD.dirs does not
exists in SYS:t UCD returns 5 (WARN) and upon WARN I let UCD scan the wanted
devices using the -m switch and a make file placed in s: and called UCD.make,
and then I scan the directory structure of RAD:. If UCD -s succeeded I just
scan the directory structure of RAD:.


Limitations
-----------
Of course it is very possible you have more than one directory with the same
name located different places on a harddrive. UCD will always choose the
first scanned directory.

        This was actually the reason for the -F switch which makes it possible
        to distinguish two directories with different cases.

        You can also decide in which order to scan different volumes and
        thereby maybe give one directory a higher priority than another di-
        rectory with the same name located on another volume.

        It is of course also possible to edit the directory structure file in
        an text editor deleting unwanted entries of directories.

NOTICE: The time UCD uses to scan the directory structure depends upon the
        number of directories, the number of files, the fragmentation of the
        disk and the speed of the disk.

        Scanning my harddrive with five partitions, about 300 directories and
        3000 files uses about 25 k of memory and takes less than 45 seconds,
        and produces a directory structure file less than 8500 bytes.

        The size of UCD.dirs of course depends upon how long your directory
        names are.


Future updates
--------------
When I release version 1.00 I had plenty of ideas for updates, but as I now has
been using UCD for quite a long time I see no actual reason for including any
of them.

The only thing I for sure will look into is my pattern matching code, because
it does as mentioned before not work exactly like is is supposed to do.

But if you have any suggestions for updates, then please send them to me, and
I will look into it if I like what you might suggest.

A new release (if any) will hopefully also happen through Fred Fish's public
domain library.


Distribution and copyright
--------------------------
UCD may be freely copied and distributed as long as no charges are made other
than to cover the time, copying costs and mailing costs. Please don't distri-
bute UCD without its accompanying doc file. Preferably distribute it along
with its archive UCD.lha or just as the archive.

UCD is copyright Uffe Holst Christiansen, 1992, and it and its accompanying
doc file may not in any way be modified or changed. Archiving and crunching
are allowed.

UCD is shareware, so if you use UCD you have the moral duty to pay the $10
shareware fee.

UCD may be included in a commercial program without written permission from
the author, if a fee of $100 are paid. The doc file still has to accompany
UCD, and no extra charges may be added for the inclusion of UCD in the com-
mercial program.

UCD may be freely distributed on coverdisks, within user groups and it may
freely be included in public domain libraries.

I encourage everybody to distribute UCD.


Acknowledgment
--------------
First of all I would like to thank Commodore for making the best computer
ever made, and Lattice for making the best programming language I ever have
come across (Borland sucks!).

I would also like to thank my friend Ebbe Holleris Petersen for helping me
with the very serious problem I had when I tried to free some allocated memo-
ry and for always being willing to tell me about the Amiga.

By the way - if you are a programmer in AmigaBASIC and want to start program-
ming in C I can advice reading the following book:

        Peter A. Darnell and Philip E. Margolis
        C: A Software Engineering Approach
        Springer-Verlag
        2. ed., 1991
        ISBN 0-387-97389-3 Springer-Verlag New York Berlin Heidelberg
        ISBN 3-540-97389-3 Springer-Verlag Berlin Heidelberg New York

I don't know the difference between the two ISBN numbers, but your local book-
store probably do. It is NOT an Amiga book but a book about standard C (ANSI
C) and it is really very good - so buy it and read it.


Final note
----------
I assume no responsibility of damage done to your hardware or software which
the use of UCD may cause. UCD is used totally on your own responsibility.

The above is just for the record. I don't expect UCD to do any damage to
hardware or software. I have used UCD for some time with no problems, and my
harddrive has been scanned at least 200 (in the future I will not update this
number, this the version 1.10 number :-) times and it still works perfectly.

Please send bug reports, shareware fees and suggestions for future updates of
UCD or just your opinion of the situation around the globe to:

        Uffe Holst Christiansen
        Kollegiebakken 9, 816
        2800 Lyngby
        Denmark



                     S U P P O R T   S H A R E W A R E

                         A M I G A   F O R E V E R


Versions
--------
v1.0	First release - 17 Sep 1992 - hopefully through Fred Fish
        ---------------------------------------------------------
        Includes the ability to scan the directory structure of both one and
        multible volumes. Includes the ability of storing the directory struc-
        ture file on disk, the ability of setting up the UCD system. And v1.0
        of course have the ability of changing the directory.

        Serious bug: UCD v1.00 has a very large memory consumption due to some
        problems I have when I free allocated memory :-(

        24 Oct 1992: Saw that UCD v1.0 appeared on Fish Disk #734 :-)

v1.05   Second release - BrainTrust release - 27 Oct 1992
        -------------------------------------------------
        Minor bug with v1.0 removed. v1.0 would remove spaces, new lines,
        carriage returns, tabs and quotes. I.e. v1.0 would interpret a direc-
        tory named " XXX X  " as 'XXX X' if you were trying to change directory
        to it.

        The code has been minimized almost by 1000 bytes before imploding.

        And most important - UCD does no longer consume a large amount of me-
        mory while scanning the directory structure and that I can thank my
        friend Ebbe (yes, that's his name!) for helping me with. It was
        actually a quite obvious thing. Thanks Ebbe :-)

        Added / and .. to make UCD able to change to the parent directory.

v1.10   Third released - 3 Dec 1992 - also hopefully through Fred Fish
        --------------------------------------------------------------
        Included a pattern matching routine - now UCD accepts wildcards. My
        implementation of pattern matching accepts the wildcards ?, #? and *.
        It was difficult, but actually easier than I had expected :-)
