home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
filemanager
/
softlinks_1
/
!SoftLinks
/
!Help
< prev
next >
Wrap
Text File
|
1996-09-17
|
18KB
|
461 lines
> !SoftLinks.!Help
Name: SoftLinks
Purpose: Symbolic file links
Author: Martin Würthner
Status: FREEWARE
Version: 1.31 (27-Sep-1996)
New features of version 1.30:
-----------------------------
- modified for StrongARM compatibility
- links are shorter now: they only take the length of the source file's
full path name
- new SWIs: SoftLinks_CreateLink, SoftLinks_LinksOff, SoftLinks_LinksOn,
SoftLinks_LinksStatus
- new *-commands: *LinksOff, *LinksOn, *LinksStatus, *CreateLink,
*CheckLink
- RISC OS 2 no longer supported
- improved, RISC OS 3 Style Guide compliant user interface
What are symbolic file links ?
------------------------------
Sometimes I wish I could have one file at several locations on my
hard disc. Simply copying the file does not solve the problem as
1) the copy takes up disc space
2) the copy is not updated if the original file is edited
Symbolic file links overcome both these problems.
A file link looks like a file but it is in fact a reference to a different
file (the so-called source file), which may be on another disc or even on
another filing system. It takes almost no disc space (basically the length
of the source file's path name). The term symbolic (or soft) file link
comes from the Unix world. SoftLinks implements symbolic links which means
that the link contains the path name of the source file, and whenever the
link is accessed (e.g. opened for reading), the symolic linking mechanism
substitutes the source files's path name for the name of the link before
the operation is performed on the file. To the outside world, however, it
still seems as if the operation was performed on the file link.
The link behaves like a copy of the source file, i.e. you cannot distinguish
the file link from the source file it references. This means that you see
all the characteristics of the source file (e.g. its length, its file type
etc.) in the Filer window.
If you access the link, the source file is accessed instead. This means that
if you double click on the link, the source file is run. If you load the
link in an application, the source file is loaded instead. However, it still
looks as if you loaded the link (e.g. the title bar in !Edit shows the name
of the link).
You can do anything with a file link that you can do with a normal file,
the whole concept is completely transparent, i.e. applications are not
aware that they access a link instead of a file.
So you can, e.g. load a link into !Edit, edit it and re-save it. This
actually alters the source file (but see below for access control).
Note that in the Desktop there is no way to find out whether a file
is an actual file or only a link. On the command line, you can use
*CheckLink <filename> to check or use *LinksOff to temporarily switch
of symbolic linking. Note that RISC OS caches directory data, so even
after switching off linking you may see the properties of the source file
in the Filer window instead of those of the link. You may have to close
and re-open the directory window to force RISC OS to re-read the
directory data. A link appears as an untyped file while linking is switched
off or while the SoftLinks module is not loaded.
Another possibility to check whether a file is a link or not is to drag the
file onto the window of the !SoftLinks application which will display the
name of the source file if the file is a link.
There are also SWI calls SoftLinks_FollowLink and SoftLinks_Off which
correspond to *CheckLink and *LinksOff. See below for further information.
SoftLinks and directories
-------------------------
SoftLinks only works with files, you cannot link directories. If you absolutely
want to provide a "linked" directory or application, you can create the
directory somewhere else and create links to all the files in the source
directory inside the destination directory. This, however, is a quite tiring
job. The SoftLinks front-end could automate this task easily, but it has been
left out deliberately in order to prevent the user from thinking that SoftLinks
does provide linked directories (after all, this is only a workaround as new
files which are created in the source directory do not by magic appear as a new
link in the destination directory). Using the documented SWIs it should be very
easy to write a little program to create "mirror" directories full of links in
case you should need it. You might also try using the *CreateLink command in
conjunction with one of these utilitites that allow you to apply *commands to
each object in a directory (e.g. FilerAct).
The SoftLinks module
--------------------
The software consists of two parts, the !SoftLinks application and the
SoftLinks module. Note that in order to make links work, only the SoftLinks
module (which is inside the !SoftLinks application) needs to be loaded.
This can be done in the !Boot file. The !SoftLinks application is only a
front-end to create links.
The !SoftLinks application
--------------------------
To create a link install the !SoftLinks application and drag a file to the
icon on the icon bar (or open the window by clicking on the icon and drag
the file onto the window). This file is called the source file.
If the source file is already a link the words 'Source file is a link to'
in the bottom left of the window and the file name of the source file of the
link is displayed.
The radio buttons can be used to specify the desired access level of the
link. The default is 'read/write/overwrite'.
Drag the file icon to a directory display or fill in a file name and press
on the Create link button in order to create a link to the source file. Note
that you can create several links to one file.
SoftLinks and LinkFS
--------------------
There is another piece of software offering links: LinkFS (written by
Tom Hughes).
It uses an image filing system (RISC OS 3 only) to provide linked directories.
However, it does not provide file links.
SoftLinks does it the other way round, i.e. it provides file links only but
not linked directories. So depending on what you want to use the links for,
you may as well have a look at LinkFS. SoftLinks and LinkFS are mutually
compatible, so you may use them simultaneously.
(Since this manual was written, some more similar pieces of software have
emerged, and I will not comment on these).
Access control
--------------
There are three different access levels of file links:
1) read-only links
Only reading operations are carried out on the source file. An error is
reported if an attempt is made to overwrite the link or to open it
with write access.
2) read/write links
All reading operations and opening the file for read/write access are
carried out on the source file. An error is reported if an attempt is
made to overwrite the link or to create a new file in its place.
3) read/write/overwrite links
The most powerful (and most dangerous) kind of file link:
All reading, writing and overwriting operations are carried out on the
source file.
This means that the file can be edited and saved back and the source
file is affected instead! Thus, the base file and the link are on the
same level. If you alter one of them, the changes are reflected in both
files.
These access levels are independent of the access attributes of the source
file. Of course, the access restrictions of the source file apply, too. This
means that you cannot write to the link if the source file is locked or does
not have write access.
Note that it is not possible to change the access level of a link. Changing
the file attributes of the link (e.g. using the Filer menu entry 'Access'
does not affect the access level of the link).
Deleting links:
---------------
As a link is only a special file you can delete it as any other file.
Note that deleting the link *never* affects the source file !
If you delete a link, the link only is deleted and its source file remains
intact. If you delete the source file while there are any links to it, the
result is that you get an error ('file xxx not found') if you try to
access the link. In this case the only thing you can do is to delete the
link (or to re-create the base file).
However, using the Filer to delete a link which has no existing associated
source file fails because RISC OS is clever and checks whether the file is
there in the first place. Of course, as the file is a symbolic link,
what RISC OS sees is that the source file is *not* there, so an error is
reported. The only way to delete the link in this case is to use the
*remove command as this does *not* check whether the file to be deleted
exists.
Other points:
-------------
Changing the directory information (e.g. file type, date stamp) is always
allowed. So changing the file type of either the source file or of the link
is reflected in both files even if the link is read-only.
Of course you may have as many links to a file as you want. It is however
not allowed to have a link to a link. The !SoftLinks application simply
creates another link to the source file if you try to create a link to a
link. The SWI SoftLinks_Create and the command *CreateLink return an
error in this case.
Copying:
--------
When copying a file link using the RISC OS2 non-interactive copy or when
using the *Copy command, the link itself is copied, i.e. copying a link
simply creates a new link to the source file.
When using the RISC OS3 interactive copy in the desktop (with FilerAction),
the source file is copied, so what you get is not another link, but a copy
of the source file.
*-commands provided by the SoftLinks module:
--------------------------------------------
Since version 1.23, the SoftLinks module provides the following *-commands:
--------------------------------------------
*LinksOff
Switch symbolic linking off temporarily. To re-enable the linking mechanism,
each execution of *LinksOff must be matched by one execution of *LinksOn.
See SWI SoftLinks_LinksOff.
--------------------------------------------
*LinksOn
Re-enable symbolic linking. See SWI SoftLinks_LinksOn.
--------------------------------------------
*LinksStatus
Displays whether symbolic linking is enabled or not. The number displayed is
the on returned by the SWI SoftLinks_LinksStatus.
--------------------------------------------
*CreateLink <source spec> <destionation spec> [<option>]
Creates a new symbolic link at the destination which refers to the source
file. The source file must exist and there must not be a file already at
the destination location.
You are strongly advised to give a full path name as the source spec. The name
is interpreted each time the link is accessed so specifying a leaf name only
may lead to unpredictable results. Note that the source spec is OS_GSTrans'ed
so you might include system variables. Future versions of SoftLinks might
canoniclise the source spec.
The option, if present must be one of the following characters (if no option
is present, r is the default):
r read-only link
w read-write link
o link with read-write-overwrite access
*CheckLink <file>
Checks whether a file is a normal file or a link.
SWIs provided by the SoftLinks module:
--------------------------------------
SWI SoftLinks_FollowLink (&46A40)
check whether a file is a link or a normal file
in : R1 = path name of file to be checked
out: R0 = 0 if file is no link
1 if file is a link
R1 = path name of source file which is referred to by link (if R0=1)
Since version 1.22, SoftLinks provides the following additional SWIs:
--------------------------------------
SWI SoftLinks_CreateLink (&46A41)
create a new symbolic link
in : R0 = 0 for a read-only link
1 for a read-write link
2 for a read-write-overwrite link
R1 = filename of source file (i.e. of the source file the link is
supposed to refer to)
R2 = filename of destination file (i.e. of the link to be created)
out: all registers preserved
Errors: Source file does not exist
Destination file exists
Source file is a link
The SWI fails if the source file does not exist or if the source file
exists, but it is a link. In order to prevent the user from accidentially
overwriting the source file by specifying the files in the wrong order,
the SWI does not overwrite files, i.e. if the destination file exists
already, it returns an error.
You are strongly advised to give a full path name as the destination file
name. The name is interpreted each time the link is accessed so specifying
a leaf name only may lead to unpredictable results. Note that in contrast to
*CreateLink, the source name is not GSTrans'ed so if you include system
variables in the source filename, the variable is evaluated every time the
link is accessed. Future versions of SoftLinks might canoniclise the source
filename.
--------------------------------------
The following SWIs work similar to the Hourglass_On and Hourglass_Off
calls. While the status is > 0, linking is switched off. Each call to
SoftLinks_LinksOff increases the status, each call to SoftLinks_LinksOn
decreases it (if the status is 0 already, calls to SoftLinks_LinksOn
are ignored). SoftLinks_LinksStatus returns the status.
SWI SoftLinks_LinksOff (&46A42)
switch linking mechanism off
in : -
out: R0 = number of times SoftLinks_LinksOn has to be called until the
linking mechanism is on again
--------------------------------------
SWI SoftLinks_LinksOn (&46A42)
switch linking mechanism on again (if SoftLinks_LinksOff has been
called several times you have to call SoftLinks_LinksOn the same
number of times in order to enable linking)
in : -
out: R0 = number of times SoftLinks_LinksOn has to be called until the
linking mechanism is on again
--------------------------------------
SWI SoftLinks_LinksStatus (&46A42)
in : -
out: R0 = number of times SoftLinks_LinksOn has to be called until the
linking mechanism is on again
Technical information:
----------------------
Links are implemented as untyped files with special load and execution
addresses: load address &400, execution address &400,&401 or &402
respectively for read-only, read/write, read/write/overwrite links.
(It is very unlikely that this clashes with other files as the load and
execution addresses are too low to be sensible).
Additionally, they contain the word SOFTLINK and the version number
(currently 100) at the beginning of the file. In the current version
the link simply contains the path name (null-terminated) of the source
file that is referenced by it at offset 11 of the file (i.e. after the
identification "SOFTLINK100" at the beginning).
The SoftLinks module claims the OS_File, OS_GBPB, OS_FSControl and the
OS_Find vector and checks whether the file which is to be accessed is a
normal file or a link. If it is a link, the path name of the source file
is substituted, the vector is called, and the original name is restored
before passing control back to the caller of the vector.
All relevant operations of RISC OS 2 and RISC OS 3 (namely most of the
OS_File, OS_Find and OS_GBPB calls and one OS_FSControl call) are monitored
by the SoftLinks module.
Not all calls are supported by the SoftLinks module. So when using
*EX or *FileInfo, you can see the real nature of the file link: An
unstamped file with load/execution address. However, this is no problem,
as all SWIs that can be used by applications to read information about
the file or to read the file itself are supported.
Operations that access the link itself instead of the source file are:
all OS_FSControl calls, exception: 4 (RUN a file)
among their corresponding *commands are: *Copy, *Wipe, *Fileinfo, *Ex
As OS_Find which is used to open/close files is among the calls that are
intercepted by the SoftLinks module, opening a link always opens the
source file. Therefore, all calls which operate on open files work.
Problems:
---------
Until now I found only one application that refused to work together with
SoftLinks, and this is DDT.
If a C source file is a file link, compilation works well, but if you try
to debug the application using DDT, it complains that it cannot find the
source file. This is because DDT removes all vector claimants and gains
control of the vectors itself. So while DDT is running to debug a program,
symbolic linking does not take place (at least not for files which are
accessed by DDT itself).
An interesting point is that SoftLinks works well with Compression
(Computer Concepts), i.e. the source file may be compressed, or the link,
or both, it simply works!
History:
--------
Version 1.00 (22-Apr-1993)
Version 1.01 (05-May-1993):
bug removed: the system crashed if a directory was deleted that had a
filer directory viewer open on it
Version 1.10 (25-Jun-1993):
bug removed: Frontend application did not run under RISC OS 2
Version 1.11 (20-Jul-1993):
small modification: the 'Create link' icon is shaded until a file is
dragged onto the window
Version 1.20 (13-Oct-1993):
now copies over command line parameters when running a file link
Version 1.21 (18-May-1996):
removed all length checks for links; there is no more a fixed length
of link files
Version 1.30 (22-Aug-1996):
new SWIs:
SoftLinks_CreateLink
SoftLinks_LinksOff, SoftLinks_LinksOn, SoftLinks_LinksStatus
new *-commands:
*LinksOff, *LinksOn, *LinksStatus, *CreateLink, *CheckLink
improved user interface
code checked and modified for StrongARM compatibility
Version 1.31 (17-Sep-1996):
bug introduced with 1.30 removed (*RUNning a link did no longer work)
Copyright notes:
----------------
This application and the SoftLinks module are FREEWARE, this means it may
be copied freely provided that no part is modified and that all files
are distributed together.
I retain the copyright of all files.
Martin Wuerthner
Jahnstrasse 18
71116 Gaertringen
Germany
e-mail: wuerthne@minnie.informatik.uni-stuttgart.de
Phone: +049-7034-928986
Fax: +049-7034-928988