filenamepath/3
filenamepath(QualName,Path,Name)
Is used to compose and decompose a fully qualified OS file name around its path and file name.
Remarks
filenamepath/3 converts between QualName on one side, and Path and Name on the other.
(i,o,o) filenamepath with this flow pattern works simply. It just separates the specified string QualName into the couple of strings: QualName = Path + Name according to the following rule:
For example, according to this rule, if one specifies: QualName = "C:\VIP\INCLUDE\IODECL.CON", then filenamepath returns: Path = "C:\VIP\INCLUDE\", Name = "IODECL.CON"
If one specifies: QualName = "INCLUDE\IODECL.CON", then filenamepath returns: Path = "INCLUDE\", Name = "IODECL.CON"
If one specifies: QualName = "IODECL.CON", then filenamepath returns: Path = "", Name = "IODECL.CON"
(o,i,i) filenamepath with this flow pattern works more tricky. The returned QualName string is not always a simple concatenation of the Path and Name strings.
Under DOS and OS/2 platforms there are the following rules:
1. String Name begins with a device name following by the backslash (doubled) character (i.e. C:\\, D:\, ...). Then string Path is ignored and
QualName = Name
2. String Name begins with a device name following by a file name that is not preceded by the backslash (doubled) character, that is:
Name = Dev:FileName
This specification means that string Name refers to the file FileName in the current directory on the specified device Dev (A,B,C,...). For example, if the current directory on the drive C is \VIP\BIN, then Name = C:VIP.EXE specifies the file C:\VIP\BIN\VIP.EXE.
In this case filenamepath ignores string Path and uses the following formula:
QualName = Dev: + CurrentDir + FileName
where CurrentDir is the current directory on the specified device Dev (see also disk).
Notice that in this case you obtains the run-time error 7015 "Invalid disk drive" if a specified device is not accessible.
3. String Name begins with the backslash (doubled) character (device root directory). Then string Path is ignored and the following formula is used:
QualName = DeviceRoot + Name
where DeviceRoot is the current device root directory (i.e. C:\, D:\, ...).
4. String Path begins with device name (i.e. C:, D:, ...). Then QualName is a concatenation of Path and Name, i.e. the following formula is used:
QualName = Path + Name
Notice that if Path does not terminate with the backslash (doubled) character, then filenamepath adds it automatically, i.e. in this case the following formula is used:
QualName = Path + "\" + Name
5. General case. In other cases the following formula is used:
QualName = CurrentDir + Path + Name
where CurrentDir is the current working directory (see also disk).
Notice that as in the previous case, filenamepath adds automatically the backslash character after Path and CurrentDir (if it is absent).
Notice that under DOS the string(s) returned will be in the upper case.
Remember that in the DOS-related versions the backslash character used to present subdirectories is an escape character. Because of this, you must always place two backslash characters when you use the backslash in a path that is written directly into the source text:"C:\\VIP\\INCLUDE\\IODECL.CON"
Notice that filenamepath does not check the correctness of the specified file and path names.Therefore, be careful specifying input strings to this predicate, otherwise you can obtain quite unusual results. For example, run the following program from the C:\WORKING directory (under DOS):
Example
Path = "txtexamp",
Name ="test\test.dat",
write("CurPath=",CurPath),nl,
write("Path=",Path),nl,
write("Name=",Name),nl,
FileNamePath(QualName,Path,Name),
write("QualName=",QualName),nl.
You obtains the following program output:
CurPath=C:\WORKING
Path=TXTEXAMP
Name=TEST\TEST.DAT
QualName=C:\WORKING\TXTEXAMP\TEST\TEST.DAT