CBL_SPLIT_FILENAME
Splits a filename into its component parts; that is, the pathname, basename
and extension.
Syntax:
call "CBL_SPLIT_FILENAME" using sj-param
split-buffer
returning status-code
Parameters:
|
Using call prototype (see Library Routines - Key) |
Picture (32-bit systems) |
sj-param |
Group predefined as cblt-splitjoin-buf containing: |
Group containing: |
|
cblte-sj-param-length |
|
cblt-x2-compx |
|
pic x(2) comp-x. |
|
cblte-sj-splitjoin-flg1 |
|
cblt-x1-compx |
|
pic x comp-x. |
|
cblte-sj-splitjoin-flg2 |
|
cblt-x1-compx |
|
pic x comp-x. |
|
cblte-sj-path-strt |
|
cblt-x2-compx |
|
pic x(2) comp-x. |
|
cblte-sj-path-len |
|
cblt-x2-compx |
|
pic x(2) comp-x. |
|
cblte-sj-cblte-sj-basename-strt |
|
cblt-x2-compx |
|
pic x(2) comp-x. |
|
cblte-sj-basename-len |
|
cblt-x2-compx |
|
pic x(2) comp-x. |
|
cblte-sj-extension-strt |
|
cblt-x2-compx |
|
pic x(2) comp-x. |
|
cblte-sj-extension-len |
|
cblt-x2-compx |
|
pic x(2) comp-x. |
|
cblte-sj-total-length |
|
cblt-x2-compx |
|
pic x(2) comp-x. |
|
cblte-sj-split-buf-len |
|
cblt-x2-compx |
|
pic x(2) comp-x. |
|
cblte-sj-join-buf-len |
|
cblt-x2-compx |
|
pic x(2) comp-x. |
|
cblte-sj-first-path-len |
|
cblt-x2-compx |
|
pic x(2) comp-x. |
split-buffer |
pic x(n). |
pic x(n). |
status-code |
See Library Routines - Key |
On Entry:
param-length |
Length of sj-param in bytes, including the two bytes for cblte-sj-param-length.
The normal value for cblte-sj-param-length is 24. |
splitjoin-flg1 |
Bit |
Meaning |
1 |
1 |
The strings are null-terminated |
0 |
The strings are space-terminated | |
0 |
1 |
The new filename is folded to upper case |
0 |
The original case is preserved. | | |
split-buf-len |
Length of split-buffer. |
split-buffer |
The string to split. |
On Exit:
cblte-sj-splitjoin-flg2 |
Bit |
Meaning |
2 |
Set if there is a significant space in the filename |
1 |
Set if there is a wildcard in the path |
0 |
Set if there is a wildcard in basename or extension | |
cblte-sj-path-strt |
Start of pathname in split-buffer, from one. |
cblte-sj-path-len |
Length of pathname; zero if there is none. This includes any following colon
(:). |
cblte-sj-basename-strt |
Start of basename in split-buffer, from one. |
cblte-sj-basename-len |
Length of basename; zero if there is none. This does not include the following
period (.). |
cblte-sj-extension-strt |
Start of extension in split-buffer, from one. |
cblte-sj-extension-len |
Length of extension; zero if there is none. This does not include the preceding
period (.). |
cblte-sj-total-length |
Total number of characters in the string. |
cblte-sj-first-path-len |
Number of characters up to and including the first backslash (\) or slash
(/) or colon (:); if split-buffer contains none of these, this parameter
= cblte-sj-path-len. |
split-buffer |
If bit 0 of cblte-sj-splitjoin-flg1 is set then this routine folds to upper
case. If bit 1 of cblte-sj-splitjoin-flg1 is unset and split-buffer was
a quoted name, possibly containing embedded spaces/quotes, then any unrequired
quote characters are removed. |
status-code |
Return status:
0 |
Success |
4 |
Illegal filename | |
Comments:
This routine can be made to fold to upper case by setting the least significant
bit (bit 0) of cblte-sj-splitjoin-flg1. If this bit is not set, the case
is preserved.
This routine can accept either null-terminated or space-terminated strings.
Setting the second least significant bit (bit 1) of cblte-sj-splitjoin-flg1
results in the routine expecting null-terminated strings. If this bit is not
set, space-terminated strings are expected.
If there are two or more periods (.) in the filename (not counting periods
(.) in the pathname), the extension returned consists of the characters between
the last period (.) and the end of the filename. The basename contains everything
up to, but not including, the last period (.).
To make a distinction between filenames with no extension and filenames with
spaces extension (that is, basenames whose last character is a period (.)),
if the extension is spaces cblte-sj-extension-len is 1 and cblte-sj-extension-strt
points to the last period (.).
Filename Routines - Example
See Also: