The FILE_LINK procedure creates UNIX file links, both regular (hard) and symbolic. FILE_LINK is available only under UNIX.
A hard link is a directory entry that references a file. UNIX allows multiple such links to exist simultaneously, meaning that a given file can be referenced by multiple names. All such links are fully equivalent references to the same file (there are no concepts of primary and secondary names). All files carry a reference count that contains the number of hard links that point to them; deleting a link to a file does not remove the actual file from the filesystem until the last hard link to the file is removed. The following limitations on hard links are enforced by the operating system:
- Hard links may not span filesystems, as hard linking is only possible within a single filesystem.
- Hard links may not be created between directories, as doing so has the potential to create infinite circular loops within the hierarchical UNIX filesystem. Such loops will confuse many system utilities, and can even cause filesystem damage.
A symbolic link is an indirect pointer to a file; its directory entry contains the name of the file to which it is linked. Symbolic links may span filesystems and may refer to directories.
Many users find symbolic links easier to understand and use. Due to their generality and lack of restriction, use symbolic links over hard links for most purposes. FILE_LINK creates symbolic links by default.
Create a symbolic link named current.dat in the current working directory, pointing to the file /master/data/saturn7.dat:
FILE_LINK, '/master/data/saturn7.dat', 'current.dat'
FILE_LINK, SourcePath, DestPath [, /ALLOW_SAME] [, /HARDLINK] [, /NOEXPAND_PATH] [, /VERBOSE]
A scalar string or string array containing the names of the files or directories to be linked.
A scalar string or string array containing the names of the destinations to which the files and directories given by SourcePath are to be linked. If more than one file is to be linked to a given destination, that destination must exist and be a directory.
Attempting to link a file to itself by specifying the same file for SourcePath and DestPath is usually considered to be an error. If the ALLOW_SAME keyword is set, no link is created and the operation is considered to be successful.
Set this keyword to create hard links. By default, FILE_LINK creates symbolic links.
Set this keyword to cause FILE_LINK to use SourcePath and DestPath exactly as specified, without expanding any wildcard characters or environment variable names included in the paths. See FILE_SEARCH for details on path expansion.
Set this keyword to cause FILE_LINK to issue an informative message for every file link operation it carries out.
Rules Used by FILE_LINK
The following rules govern how FILE_LINK operates:
- The arguments to FILE_LINK can be scalar or array. If both arguments are arrays, they must contain the same number of elements, and the files are paired, with each file from SourcePath being linked to the corresponding file in the DestPath. If SourcePath is an array and DestPath is a scalar, all links are created in the single location given by DestPath, which must exist and be a directory.
- Elements of SourcePath may use wildcard characters (as accepted by the FILE_SEARCH function) to specify multiple files. All the files matched for a given element of SourcePath are linked to the corresponding element of DestPath. If multiple files are linked to a single element of DestPath, that element must exist and be a directory.
- If a file specified in DestPath does not exist, the corresponding file from SourcePath is linked using the name specified by DestPath. Any parent directories to the filename specified by DestPath must already exist.
- If DestPath names an existing regular file, FILE_LINK will not overwrite it.
- If DestPath names an existing directory, a link with the same name as the source file is created in the directory. This is primarily of interest with hard links.
COPY_LUN, FILE_COPY, FILE_MOVE, FILE_READLINK, General File Access