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

sj-param
Group defined as cblt-splitjoin-buf containing:
01 cblt-splitjoin-buf                typedef.
  03 cblte-sj-param-length           cblt-x2-compx. 	*> pic x(2) comp-x.
  03 cblte-sj-split-join-flag1       cblt-x1-compx. 	*> pic x comp-x.
  03 cblte-sj-split-join-flag2       cblt-x1-compx. 	*> pic x comp-x.
  03 cblte-sj-path-offset            cblt-x2-compx. 	*> pic x(2) comp-x.
  03 cblte-sj-path-length            cblt-x2-compx. 	*> pic x(2) comp-x.
  03 cblte-sj-basename-offset        cblt-x2-compx. 	*> pic x(2) comp-x.
  03 cblte-sj-basename-length        cblt-x2-compx. 	*> pic x(2) comp-x.
  03 cblte-sj-extension-offset       cblt-x2-compx. 	*> pic x(2) comp-x.
  03 cblte-sj-extension-length       cblt-x2-compx. 	*> pic x(2) comp-x.
  03 cblte-sj-total-length           cblt-x2-compx. 	*> pic x(2) comp-x.
  03 cblte-sj-split-buf-len          cblt-x2-compx. 	*> pic x(2) comp-x.
  03 cblte-sj-join-buf-len           cblt-x2-compx. 	*> pic x(2) comp-x.
  03 cblte-sj-first-component-length cblt-x2-compx. 	*> pic x(2) comp-x.
split-buffer
Call prototype: pic x(n).
Picture: pic x(n).
status-code
See Library Routines - Key

On Entry:

cblte-sj-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.
cblte-sj-split-join-flag1
Bit 1
1 The strings are null-terminated
0 The strings are space-terminated
Bit 0
1 The new filename is folded to upper case
0 The original case is preserved.
cblte-sj-split-buf-len
Length of split-buffer
cblte-sj-split-buffer
The string to split.

On Exit:

cblte-sj-split-join-flag2
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-offset
Start of pathname in split-buffer, from one.
cblte-sj-path-length
Length of pathname; zero if there is none. This includes any following colon (:).
cblte-sj-basename-offset
Start of basename in split-buffer, from one.
cblte-sj-basename-length
Length of basename; zero if there is none. This does not include the following period (.).
cblte-sj-extension-offset
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-component-length
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-split-join-flag1 is set then this routine folds to upper case. If bit 1 of cblte-sj-split-join-flag1 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-split-join-flag1. 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-split-join-flag1 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-length is 1 and cblte-sj-extension-offset points to the last period (.).