Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 62bef00

Browse files
committedJun 19, 2025·
Consistent naming
1 parent ca867f8 commit 62bef00

11 files changed

+136
-136
lines changed
 

‎doc/specs/stdlib_system.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ The file is removed from the filesystem if the operation is successful. If the o
533533
{!example/system/example_delete_file.f90!}
534534
```
535535

536-
## `joinpath` - Joins the provided paths according to the OS
536+
## `join_path` - Joins the provided paths according to the OS
537537

538538
### Status
539539

@@ -546,9 +546,9 @@ i.e `\` for windows and `/` for others
546546

547547
### Syntax
548548

549-
`res = ` [[stdlib_system(module):joinpath(interface)]] ` (p1, p2)`
549+
`res = ` [[stdlib_system(module):join_path(interface)]] ` (p1, p2)`
550550

551-
`res = ` [[stdlib_system(module):joinpath(interface)]] ` (p)`
551+
`res = ` [[stdlib_system(module):join_path(interface)]] ` (p)`
552552

553553
### Class
554554
Pure function
@@ -565,7 +565,7 @@ The resultant path.
565565

566566
## `operator(/)`
567567

568-
Alternative syntax to`joinpath` using an overloaded operator. Join two paths according to the platform specific path-separator.
568+
Alternative syntax to`join_path` using an overloaded operator. Join two paths according to the platform specific path-separator.
569569

570570
### Status
571571

@@ -595,7 +595,7 @@ The result is an `allocatable` character string
595595
{!example/system/example_path_join.f90!}
596596
```
597597

598-
## `splitpath` - splits a path immediately following the last separator
598+
## `split_path` - splits a path immediately following the last separator
599599

600600
### Status
601601

@@ -608,7 +608,7 @@ splitting it into most of the times a directory and a file name.
608608

609609
### Syntax
610610

611-
`call `[[stdlib_system(module):splitpath(interface)]]`(p, head, tail)`
611+
`call `[[stdlib_system(module):split_path(interface)]]`(p, head, tail)`
612612

613613
### Class
614614
Subroutine
@@ -632,10 +632,10 @@ The splitted path. `head` and `tail`.
632632
### Example
633633

634634
```fortran
635-
{!example/system/example_path_splitpath.f90!}
635+
{!example/system/example_path_split_path.f90!}
636636
```
637637

638-
## `basename` - The last part of a path
638+
## `base_name` - The last part of a path
639639

640640
### Status
641641

@@ -647,7 +647,7 @@ This function returns the last part of a path after removing trailing path separ
647647

648648
### Syntax
649649

650-
`res = ` [[stdlib_system(module):basename(interface)]]`(p)`
650+
`res = ` [[stdlib_system(module):base_name(interface)]]`(p)`
651651

652652
### Class
653653
Function
@@ -658,7 +658,7 @@ Function
658658

659659
### Behavior
660660

661-
- The `tail` of `stdlib_system(module):splitpath(interface)` is exactly what is returned. Same Behavior.
661+
- The `tail` of `stdlib_system(module):split_path(interface)` is exactly what is returned. Same Behavior.
662662

663663
### Return values
664664

@@ -667,10 +667,10 @@ A character string.
667667
### Example
668668

669669
```fortran
670-
{!example/system/example_path_basename.f90!}
670+
{!example/system/example_path_base_name.f90!}
671671
```
672672

673-
## `dirname` - Everything except the last part of the path
673+
## `dir_name` - Everything except the last part of the path
674674

675675
### Status
676676

@@ -682,7 +682,7 @@ This function returns everything except the last part of a path.
682682

683683
### Syntax
684684

685-
`res = ` [[stdlib_system(module):dirname(interface)]]`(p)`
685+
`res = ` [[stdlib_system(module):dir_name(interface)]]`(p)`
686686

687687
### Class
688688
Function
@@ -693,7 +693,7 @@ Function
693693

694694
### Behavior
695695

696-
- The `head` of `stdlib_system(module):splitpath(interface)` is exactly what is returned. Same Behavior.
696+
- The `head` of `stdlib_system(module):split_path(interface)` is exactly what is returned. Same Behavior.
697697

698698
### Return values
699699

@@ -702,5 +702,5 @@ A character string.
702702
### Example
703703

704704
```fortran
705-
{!example/system/example_path_dirname.f90!}
705+
{!example/system/example_path_dir_name.f90!}
706706
```

‎example/system/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ADD_EXAMPLE(process_5)
1111
ADD_EXAMPLE(process_6)
1212
ADD_EXAMPLE(process_7)
1313
ADD_EXAMPLE(sleep)
14-
ADD_EXAMPLE(path_basename)
15-
ADD_EXAMPLE(path_dirname)
1614
ADD_EXAMPLE(path_join)
17-
ADD_EXAMPLE(path_splitpath)
15+
ADD_EXAMPLE(path_split_path)
16+
ADD_EXAMPLE(path_base_name)
17+
ADD_EXAMPLE(path_dir_name)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
! Usage of base_name
2+
program example_path_base_name
3+
use stdlib_system, only: base_name, ISWIN
4+
character(len=:), allocatable :: p1
5+
6+
if( ISWIN ) then
7+
p1 = 'C:\Users'
8+
else
9+
p1 = '/home'
10+
endif
11+
12+
print *, 'base name of '// p1 // ' -> ' // base_name(p1)
13+
! base name of C:\Users -> Users
14+
! OR
15+
! base name of /home -> home
16+
end program example_path_base_name

‎example/system/example_path_basename.f90

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
! Usage of dir_name
2+
program example_path_dir_name
3+
use stdlib_system, only: dir_name, ISWIN
4+
character(len=:), allocatable :: p1, head, tail
5+
6+
if( ISWIN ) then
7+
p1 = 'C:\Users' ! C:\Users
8+
else
9+
p1 = '/home' ! /home
10+
endif
11+
12+
print *, 'dir_name of '// p1 // ' -> ' // dir_name(p1)
13+
! dir_name of C:\Users -> C:\
14+
! OR
15+
! dir_name of /home -> /
16+
end program example_path_dir_name

‎example/system/example_path_dirname.f90

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎example/system/example_path_join.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
! Usage of joinpath, operator(/)
1+
! Usage of join_path, operator(/)
22
program example_path_join
3-
use stdlib_system, only: joinpath, operator(/), ISWIN
3+
use stdlib_system, only: join_path, operator(/), ISWIN
44
character(len=:), allocatable :: p1, p2, p3
55
character(len=20) :: parr(4)
66

77
if( ISWIN ) then
88
p1 = 'C:'/'Users'/'User1'/'Desktop'
9-
p2 = joinpath('C:\Users\User1', 'Desktop')
9+
p2 = join_path('C:\Users\User1', 'Desktop')
1010
parr = [character(len=20) :: 'C:', 'Users', 'User1', 'Desktop']
11-
p3 = joinpath(parr)
11+
p3 = join_path(parr)
1212
else
1313
p1 = ''/'home'/'User1'/'Desktop'
14-
p2 = joinpath('/home/User1', 'Desktop')
14+
p2 = join_path('/home/User1', 'Desktop')
1515
parr = [character(len=20) :: '', 'home', 'User1', 'Desktop']
16-
p3 = joinpath(parr)
16+
p3 = join_path(parr)
1717
end if
1818

1919
! (p1 == p2 == p3) = '/home/User1/Desktop' OR 'C:\Users\User1\Desktop'
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
! Usage of splitpath, dirname, basename
2-
program example_path_splitpath
3-
use stdlib_system, only: joinpath, splitpath, ISWIN
1+
! Usage of split_path
2+
program example_path_split_path
3+
use stdlib_system, only: join_path, split_path, ISWIN
44
character(len=:), allocatable :: p1, head, tail
55

66
if( ISWIN ) then
7-
p1 = joinpath('C:\Users\User1', 'Desktop') ! C:\Users\User1\Desktop
7+
p1 = join_path('C:\Users\User1', 'Desktop') ! C:\Users\User1\Desktop
88
else
9-
p1 = joinpath('/home/User1', 'Desktop') ! /home/User1/Desktop
9+
p1 = join_path('/home/User1', 'Desktop') ! /home/User1/Desktop
1010
endif
1111

12-
call splitpath(p1, head, tail)
12+
call split_path(p1, head, tail)
1313
! head = /home/User1 OR C:\Users\User1, tail = Desktop
1414
print *, p1 // " -> " // head // " + " // tail
1515
! C:\Users\User1\Desktop -> C:\Users\User1 + Desktop
1616
! OR
1717
! /home/User1/Desktop -> /home/User1 + Desktop
1818

19-
call splitpath(head, p1, tail)
19+
call split_path(head, p1, tail)
2020
! p1 = /home OR C:\Users, tail = User1
2121
print *, head // " -> " // p1 // " + " // tail
2222
! C:\Users\User1 -> C:\Users + User1
2323
! OR
2424
! /home/User1 -> /home + User1
25-
end program example_path_splitpath
25+
end program example_path_split_path

‎src/stdlib_system.F90

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ module stdlib_system
9393
logical, parameter, public :: ISWIN = .false.
9494
#endif
9595

96-
public :: joinpath
96+
public :: join_path
9797
public :: operator(/)
98-
public :: splitpath
99-
public :: basename
100-
public :: dirname
98+
public :: split_path
99+
public :: base_name
100+
public :: dir_name
101101

102102
!! version: experimental
103103
!!
@@ -565,12 +565,12 @@ end function process_get_ID
565565

566566
end interface
567567

568-
interface joinpath
568+
interface join_path
569569
!! version: experimental
570570
!!
571571
!!### Summary
572572
!! join the paths provided according to the OS-specific path-separator
573-
!! ([Specification](../page/specs/stdlib_system.html#joinpath))
573+
!! ([Specification](../page/specs/stdlib_system.html#join_path))
574574
!!
575575
module pure function join2(p1, p2) result(path)
576576
character(:), allocatable :: path
@@ -581,7 +581,7 @@ module pure function joinarr(p) result(path)
581581
character(:), allocatable :: path
582582
character(*), intent(in) :: p(:)
583583
end function joinarr
584-
end interface joinpath
584+
end interface join_path
585585

586586
interface operator(/)
587587
!! version: experimental
@@ -596,54 +596,54 @@ module pure function join_op(p1, p2) result(path)
596596
end function join_op
597597
end interface operator(/)
598598

599-
interface splitpath
599+
interface split_path
600600
!! version: experimental
601601
!!
602602
!!### Summary
603603
!! splits the path immediately following the final path-separator
604604
!! separating into typically a directory and a file name.
605-
!! ([Specification](../page/specs/stdlib_system.html#splitpath))
605+
!! ([Specification](../page/specs/stdlib_system.html#split_path))
606606
!!
607607
!!### Description
608608
!! If the path is empty `head`='.' and tail=''
609609
!! If the path only consists of separators, `head` is set to the separator and tail is empty
610610
!! If the path is a root directory, `head` is set to that directory and tail is empty
611611
!! `head` ends with a path-separator iff the path appears to be a root directory or a child of the root directory
612-
module subroutine splitpath(p, head, tail)
612+
module subroutine split_path(p, head, tail)
613613
character(*), intent(in) :: p
614614
character(:), allocatable, intent(out) :: head, tail
615-
end subroutine splitpath
616-
end interface splitpath
615+
end subroutine split_path
616+
end interface split_path
617617

618-
interface basename
618+
interface base_name
619619
!! version: experimental
620620
!!
621621
!!### Summary
622-
!! returns the basename (last component) of the provided path
623-
!! ([Specification](../page/specs/stdlib_system.html#basename))
622+
!! returns the base name (last component) of the provided path
623+
!! ([Specification](../page/specs/stdlib_system.html#base_name))
624624
!!
625625
!!### Description
626-
!! The value returned is the `tail` of the interface `splitpath`
627-
module function basename(p) result(base)
626+
!! The value returned is the `tail` of the interface `split_path`
627+
module function base_name(p) result(base)
628628
character(:), allocatable :: base
629629
character(*), intent(in) :: p
630-
end function basename
631-
end interface basename
630+
end function base_name
631+
end interface base_name
632632

633-
interface dirname
633+
interface dir_name
634634
!! version: experimental
635635
!!
636636
!!### Summary
637637
!! returns everything but the last component of the provided path
638-
!! ([Specification](../page/specs/stdlib_system.html#dirname))
638+
!! ([Specification](../page/specs/stdlib_system.html#dir_name))
639639
!!
640640
!!### Description
641-
!! The value returned is the `head` of the interface `splitpath`
642-
module function dirname(p) result(base)
641+
!! The value returned is the `head` of the interface `split_path`
642+
module function dir_name(p) result(base)
643643
character(:), allocatable :: base
644644
character(*), intent(in) :: p
645-
end function dirname
646-
end interface dirname
645+
end function dir_name
646+
end interface dir_name
647647

648648

649649
contains

‎src/stdlib_system_path.f90

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ module pure function join_op(p1, p2) result(path)
2020
character(:), allocatable :: path
2121
character(*), intent(in) :: p1, p2
2222

23-
path = joinpath(p1, p2)
23+
path = join_path(p1, p2)
2424
end function join_op
2525

26-
module subroutine splitpath(p, head, tail)
26+
module subroutine split_path(p, head, tail)
2727
character(*), intent(in) :: p
2828
character(:), allocatable, intent(out) :: head, tail
2929
character(:), allocatable :: temp
@@ -62,19 +62,19 @@ module subroutine splitpath(p, head, tail)
6262
end if
6363

6464
tail = temp(len(temp)-i+2:)
65-
end subroutine splitpath
65+
end subroutine split_path
6666

67-
module function basename(p) result(base)
67+
module function base_name(p) result(base)
6868
character(:), allocatable :: base, temp
6969
character(*), intent(in) :: p
7070

71-
call splitpath(p, temp, base)
72-
end function basename
71+
call split_path(p, temp, base)
72+
end function base_name
7373

74-
module function dirname(p) result(dir)
74+
module function dir_name(p) result(dir)
7575
character(:), allocatable :: dir, temp
7676
character(*), intent(in) :: p
7777

78-
call splitpath(p, dir, temp)
79-
end function dirname
78+
call split_path(p, dir, temp)
79+
end function dir_name
8080
end submodule stdlib_system_path

‎test/system/test_path.f90

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module test_path
22
use testdrive, only : new_unittest, unittest_type, error_type, check, skip_test
3-
use stdlib_system, only: joinpath, operator(/), splitpath, ISWIN
3+
use stdlib_system, only: join_path, operator(/), split_path, ISWIN
44
implicit none
55
contains
66
!> Collect all exported unit tests
@@ -9,9 +9,9 @@ subroutine collect_suite(testsuite)
99
type(unittest_type), allocatable, intent(out) :: testsuite(:)
1010

1111
testsuite = [ &
12-
new_unittest('test_joinpath', test_joinpath), &
13-
new_unittest('test_joinpath_operator', test_joinpath_op), &
14-
new_unittest('test_splitpath', test_splitpath) &
12+
new_unittest('test_join_path', test_join_path), &
13+
new_unittest('test_join_path_operator', test_join_path_op), &
14+
new_unittest('test_split_path', test_split_path) &
1515
]
1616
end subroutine collect_suite
1717

@@ -27,92 +27,92 @@ subroutine checkpath(error, funcname, expected, got)
2727

2828
end subroutine checkpath
2929

30-
subroutine test_joinpath(error)
30+
subroutine test_join_path(error)
3131
type(error_type), allocatable, intent(out) :: error
3232
character(len=:), allocatable :: path
3333
character(len=20) :: paths(5)
3434

3535
if (ISWIN) then
36-
path = joinpath('C:\Users', 'Alice')
37-
call checkpath(error, 'joinpath', 'C:\Users\Alice', path)
36+
path = join_path('C:\Users', 'Alice')
37+
call checkpath(error, 'join_path', 'C:\Users\Alice', path)
3838
if (allocated(error)) return
3939

4040
paths = [character(20) :: 'C:','Users','Bob','Pictures','2025']
41-
path = joinpath(paths)
41+
path = join_path(paths)
4242

43-
call checkpath(error, 'joinpath', 'C:\Users\Bob\Pictures\2025', path)
43+
call checkpath(error, 'join_path', 'C:\Users\Bob\Pictures\2025', path)
4444
if (allocated(error)) return
4545
else
46-
path = joinpath('/home', 'Alice')
47-
call checkpath(error, 'joinpath', '/home/Alice', path)
46+
path = join_path('/home', 'Alice')
47+
call checkpath(error, 'join_path', '/home/Alice', path)
4848
if (allocated(error)) return
4949

5050
paths = [character(20) :: '','home','Bob','Pictures','2025']
51-
path = joinpath(paths)
51+
path = join_path(paths)
5252

53-
call checkpath(error, 'joinpath', '/home/Bob/Pictures/2025', path)
53+
call checkpath(error, 'join_path', '/home/Bob/Pictures/2025', path)
5454
if (allocated(error)) return
5555
end if
56-
end subroutine test_joinpath
56+
end subroutine test_join_path
5757

5858
!> Test the operator
59-
subroutine test_joinpath_op(error)
59+
subroutine test_join_path_op(error)
6060
type(error_type), allocatable, intent(out) :: error
6161
character(len=:), allocatable :: path
6262

6363
if (ISWIN) then
6464
path = 'C:'/'Users'/'Alice'/'Desktop'
65-
call checkpath(error, 'joinpath operator', 'C:\Users\Alice\Desktop', path)
65+
call checkpath(error, 'join_path operator', 'C:\Users\Alice\Desktop', path)
6666
if (allocated(error)) return
6767
else
6868
path = ''/'home'/'Alice'/'.config'
69-
call checkpath(error, 'joinpath operator', '/home/Alice/.config', path)
69+
call checkpath(error, 'join_path operator', '/home/Alice/.config', path)
7070
if (allocated(error)) return
7171
end if
72-
end subroutine test_joinpath_op
72+
end subroutine test_join_path_op
7373

74-
subroutine test_splitpath(error)
74+
subroutine test_split_path(error)
7575
type(error_type), allocatable, intent(out) :: error
7676
character(len=:), allocatable :: head, tail
7777

78-
call splitpath('', head, tail)
79-
call checkpath(error, 'splitpath-head', '.', head)
78+
call split_path('', head, tail)
79+
call checkpath(error, 'split_path-head', '.', head)
8080
if (allocated(error)) return
81-
call checkpath(error, 'splitpath-tail', '', tail)
81+
call checkpath(error, 'split_path-tail', '', tail)
8282
if (allocated(error)) return
8383

8484
if (ISWIN) then
85-
call splitpath('\\\\', head, tail)
86-
call checkpath(error, 'splitpath-head', '\', head)
85+
call split_path('\\\\', head, tail)
86+
call checkpath(error, 'split_path-head', '\', head)
8787
if (allocated(error)) return
88-
call checkpath(error, 'splitpath-tail', '', tail)
88+
call checkpath(error, 'split_path-tail', '', tail)
8989
if (allocated(error)) return
9090

91-
call splitpath('C:\', head, tail)
92-
call checkpath(error, 'splitpath-head', 'C:\', head)
91+
call split_path('C:\', head, tail)
92+
call checkpath(error, 'split_path-head', 'C:\', head)
9393
if (allocated(error)) return
94-
call checkpath(error, 'splitpath-tail', '', tail)
94+
call checkpath(error, 'split_path-tail', '', tail)
9595
if (allocated(error)) return
9696

97-
call splitpath('C:\Users\Alice\\\\\', head, tail)
98-
call checkpath(error, 'splitpath-head', 'C:\Users', head)
97+
call split_path('C:\Users\Alice\\\\\', head, tail)
98+
call checkpath(error, 'split_path-head', 'C:\Users', head)
9999
if (allocated(error)) return
100-
call checkpath(error, 'splitpath-tail', 'Alice', tail)
100+
call checkpath(error, 'split_path-tail', 'Alice', tail)
101101
if (allocated(error)) return
102102
else
103-
call splitpath('/////', head, tail)
104-
call checkpath(error, 'splitpath-head', '/', head)
103+
call split_path('/////', head, tail)
104+
call checkpath(error, 'split_path-head', '/', head)
105105
if (allocated(error)) return
106-
call checkpath(error, 'splitpath-tail', '', tail)
106+
call checkpath(error, 'split_path-tail', '', tail)
107107
if (allocated(error)) return
108108

109-
call splitpath('/home/Alice/foo/bar.f90///', head, tail)
110-
call checkpath(error, 'splitpath-head', '/home/Alice/foo', head)
109+
call split_path('/home/Alice/foo/bar.f90///', head, tail)
110+
call checkpath(error, 'split_path-head', '/home/Alice/foo', head)
111111
if (allocated(error)) return
112-
call checkpath(error, 'splitpath-tail', 'bar.f90', tail)
112+
call checkpath(error, 'split_path-tail', 'bar.f90', tail)
113113
if (allocated(error)) return
114114
end if
115-
end subroutine test_splitpath
115+
end subroutine test_split_path
116116

117117
end module test_path
118118

0 commit comments

Comments
 (0)
Please sign in to comment.