Generate and return the basename part of the input path
(i.e., all characters that appear after the last directory separator in the path
).
See also the details of the documentation of the generic interface getIndexDirName and getDirName.
- Parameters
-
[in] | path | : The input scalar character of default kind SK of arbitrary length type parameter containing the path to split.<br |
[in] | dirsep | : The input scalar character of default kind SK of arbitrary length type parameter containing the runtime directory separator(s).
The directory separator can be obtained from either the dirsep component of an object of type shell_type or getDirSep.
The directory separator is \ or / in Windows-based terminals (e.g., CMD or PowerShell) and / in POSIX-compliant shells.
When in doubt (for example, in Windows terminals), dirsep can be set to multiple characters, for example dirsep = "/\" .
In such a case, the input path will be scanned for the presence of any of the individual characters in dirsep .
|
[in] | style | : The input scalar that can be,
-
the constant verbatim or an object of type verbatim_type implying the use of the ParaMonte style described above in extracting the output
basename .
(optional. If missing, the default behavior corresponds to that of the basename command on POSIX systems. See examples below.) |
- Returns
basename
: The output allocatable
scalar character
of default kind SK containing the basename segment of the input path
.
Possible calling interfaces ⛓
character(:, SK), allocatable :: basename
Generate and return the basename part of the input path (i.e., all characters that appear after the l...
This module contains classes and procedures for manipulating system file/folder paths.
type(verbatim_type), parameter verbatim
The scalar constant of type verbatim_type that can be used to signify the verbatim interpretation of ...
- Warning
- The condition
0 < len(dirsep)
must hold for the corresponding input arguments.
This condition is verified only if the library is built with the preprocessor macro CHECK_ENABLED=1
.
-
The
pure
procedure(s) documented herein become impure
when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1
.
By default, these procedures are pure
in release
build and impure
in debug
and testing
builds.
- Note
- See getIndexBaseName for a faster method of getting the
basename
segment of a path that avoids memory allocation.
- See also
- getDirName
getExtName
getFileName
getBaseName
getIndexDirName
getIndexExtName
getIndexBaseName
Example usage ⛓
11 character(:),
allocatable :: path
13 type(display_type) :: disp
17 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
18 call disp%show(
"! Get the basename of a POSIX-compliant path.")
19 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
25 call disp%show(
"getBaseName(path, SK_'/')")
27 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
34 call disp%show(
"getBaseName(path, SK_'/')")
36 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
43 call disp%show(
"getBaseName(path, SK_'/')")
45 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
52 call disp%show(
"getBaseName(path, SK_'/')")
54 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
61 call disp%show(
"getBaseName(path, SK_'/')")
63 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
70 call disp%show(
"getBaseName(path, SK_'/')")
72 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
79 call disp%show(
"getBaseName(path, SK_'/')")
81 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
88 call disp%show(
"getBaseName(path, SK_'/')")
90 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
97 call disp%show(
"getBaseName(path, SK_'/')")
99 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
106 call disp%show(
"getBaseName(path, SK_'/')")
108 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
115 call disp%show(
"getBaseName(path, SK_'/')")
117 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
124 call disp%show(
"getBaseName(path, SK_'/')")
126 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
133 call disp%show(
"getBaseName(path, SK_'/')")
135 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
142 call disp%show(
"getBaseName(path, SK_'/')")
144 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
149 call disp%show(
"path = SK_'//.//a'")
151 call disp%show(
"getBaseName(path, SK_'/')")
153 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
158 call disp%show(
"path = SK_'paramonte'")
159 path
= SK_
'paramonte'
160 call disp%show(
"getBaseName(path, SK_'/')")
162 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
167 call disp%show(
"path = SK_'/paramonte'")
168 path
= SK_
'/paramonte'
169 call disp%show(
"getBaseName(path, SK_'/')")
171 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
176 call disp%show(
"path = SK_'paramonte/'")
177 path
= SK_
'paramonte/'
178 call disp%show(
"getBaseName(path, SK_'/')")
180 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
185 call disp%show(
"path = SK_'./paramonte'")
186 path
= SK_
'./paramonte'
187 call disp%show(
"getBaseName(path, SK_'/')")
189 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
194 call disp%show(
"path = SK_'./paramonte/'")
195 path
= SK_
'./paramonte/'
196 call disp%show(
"getBaseName(path, SK_'/')")
198 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
203 call disp%show(
"path = SK_'./paramonte/parallel/library.txt'")
204 path
= SK_
'./paramonte/parallel/library.txt'
205 call disp%show(
"getBaseName(path, SK_'/')")
207 call disp%show(
"getBaseName(path, SK_'/', verbatim)")
212 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
213 call disp%show(
"! Get the basename of a Windows-compliant path.")
214 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
220 call disp%show(
"getBaseName(path, SK_'/\')")
222 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
229 call disp%show(
"getBaseName(path, SK_'/\')")
231 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
238 call disp%show(
"getBaseName(path, SK_'/\')")
240 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
247 call disp%show(
"getBaseName(path, SK_'/\')")
249 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
256 call disp%show(
"getBaseName(path, SK_'/\')")
258 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
265 call disp%show(
"getBaseName(path, SK_'/\')")
267 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
274 call disp%show(
"getBaseName(path, SK_'/\')")
276 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
283 call disp%show(
"getBaseName(path, SK_'/\')")
285 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
292 call disp%show(
"getBaseName(path, SK_'/\')")
294 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
301 call disp%show(
"getBaseName(path, SK_'/\')")
303 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
310 call disp%show(
"getBaseName(path, SK_'/\')")
312 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
319 call disp%show(
"getBaseName(path, SK_'/\')")
321 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
328 call disp%show(
"getBaseName(path, SK_'/\')")
330 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
335 call disp%show(
"path = SK_'\\.//a'")
337 call disp%show(
"getBaseName(path, SK_'/\')")
339 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
344 call disp%show(
"path = SK_'paramonte'")
345 path
= SK_
'paramonte'
346 call disp%show(
"getBaseName(path, SK_'/\')")
348 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
353 call disp%show(
"path = SK_'/paramonte\'")
354 path
= SK_
'/paramonte\'
355 call disp%show(
"getBaseName(path, SK_'/\')")
357 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
362 call disp%show(
"path = SK_'paramonte/\'")
363 path
= SK_
'paramonte/\'
364 call disp%show(
"getBaseName(path, SK_'/\')")
366 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
371 call disp%show(
"path = SK_'./paramonte'")
372 path
= SK_
'./paramonte'
373 call disp%show(
"getBaseName(path, SK_'/\')")
375 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
380 call disp%show(
"path = SK_'./paramonte/'")
381 path
= SK_
'./paramonte/'
382 call disp%show(
"getBaseName(path, SK_'/\')")
384 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
389 call disp%show(
"path = SK_'.\paramonte/parallel\library.txt'")
390 path
= SK_
'.\paramonte/parallel\library.txt'
391 call disp%show(
"getBaseName(path, SK_'/\')")
393 call disp%show(
"getBaseName(path, SK_'/\', verbatim)")
This is a generic method of the derived type display_type with pass attribute.
This is a generic method of the derived type display_type with pass attribute.
This module contains classes and procedures for input/output (IO) or generic display operations on st...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
119path
= SK_
'/paramonte'
126path
= SK_
'paramonte/'
133path
= SK_
'./paramonte'
140path
= SK_
'./paramonte/'
147path
= SK_
'./paramonte/parallel/library.txt'
264path
= SK_
'/paramonte\'
271path
= SK_
'paramonte/\'
278path
= SK_
'./paramonte'
285path
= SK_
'./paramonte/'
292path
= SK_
'.\paramonte/parallel\library.txt'
- Test:
- test_pm_sysPath
- Todo:
- High Priority: The current Fortran standard 202x does not allow passing characters of non-default kind to the intrinsic Fortran statements and procedures.
As such, the implementation of this procedure for non-default character
kinds leads to compile-time kind mismatch errors.
This procedure should be converted back to a generic interface in the future when non-default character kinds are also fully supported by the intrinsic functions.
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
-
If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
-
If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
- Copyright
- Computational Data Science Lab
- Author:
- Amir Shahmoradi, Tuesday March 7, 2017, 7:03 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin
Definition at line 6050 of file pm_sysPath.F90.