Skip to content

Commit b6a92e8

Browse files
authored
Merge branch 'master' into cwd
2 parents 3c0fd24 + 60f5308 commit b6a92e8

15 files changed

+850
-176
lines changed

.github/collab.sh

100644100755
File mode changed.

doc/specs/stdlib_ascii.md

Lines changed: 530 additions & 3 deletions
Large diffs are not rendered by default.

doc/specs/stdlib_system.md

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -543,12 +543,12 @@ Experimental
543543

544544
### Description
545545

546-
It creates an empty directory.
546+
It creates an empty directory with default permissions.
547547
It is designed to work across multiple platforms. On Windows, paths with both forward `/` and backward `\` slashes are accepted.
548548

549549
### Syntax
550550

551-
`call [[stdlib_system(module):make_directory(subroutine)]] (path, mode, err)`
551+
`call [[stdlib_system(module):make_directory(subroutine)]] (path [,err])`
552552

553553
### Class
554554

@@ -558,13 +558,11 @@ Subroutine
558558

559559
`path`: Shall be a character string containing the path of the directory to create. It is an `intent(in)` argument.
560560

561-
`mode`: Shall be a scalar integer indicating the permission bits required (Not applicable to Windows). It is an `optional, intent(in)` argument.
562-
563-
`err`: Shall be of type `state_type`, for error handling. It is an `optional, intent(out)` argument.
561+
`err`(optional): Shall be of type `state_type`, and is used for error handling. It is an `optional, intent(out)` argument.
564562

565563
### Return values
566564

567-
The `err` is set accordingly.
565+
`err` is an optional state return flag. If not requested and an error occurs, an `FS_ERROR` will trigger an error stop.
568566

569567
### Example
570568

@@ -574,20 +572,20 @@ The `err` is set accordingly.
574572

575573
---
576574

577-
## `remove_directory` - Removes an empty directory
575+
## `make_directory_all` - Creates an empty directory with all its parent directories
578576

579577
### Status
580578

581579
Experimental
582580

583581
### Description
584582

585-
It deletes an empty directory.
586-
It is designed to work across multiple platforms. On Windows, paths with both forward `/` and backward `\` slashes are accepted.
583+
It creates an empty directory with default permissions.
584+
It also creates all the necessary parent directories in the path if they do not exist already.
587585

588586
### Syntax
589587

590-
`call [[stdlib_system(module):remove_directory(subroutine)]] (path, err)`
588+
`call [[stdlib_system(module):make_directory_all(subroutine)]] (path [,err])`
591589

592590
### Class
593591

@@ -597,79 +595,79 @@ Subroutine
597595

598596
`path`: Shall be a character string containing the path of the directory to create. It is an `intent(in)` argument.
599597

600-
`err`: Shall be of type `state_type`, for error handling. It is an `intent(out)` argument.
598+
`err`(optional): Shall be of type `state_type`, and is used for error handling. It is an `optional, intent(out)` argument.
601599

602600
### Return values
603601

604-
The `err` is set accordingly.
602+
`err` is an optional state return flag. If not requested and an error occurs, an `FS_ERROR` will trigger an error stop.
605603

606604
### Example
607605

608606
```fortran
609-
{!example/system/example_remove_directory.f90!}
607+
{!example/system/example_make_directory.f90!}
610608
```
611609

612610
---
613611

614-
## `get_cwd` - Gets the current working directory
612+
## `remove_directory` - Removes an empty directory
615613

616614
### Status
617615

618616
Experimental
619617

620618
### Description
621619

622-
It gets the current working directory associated with the process calling this subroutine.
620+
It deletes an empty directory.
623621
It is designed to work across multiple platforms. On Windows, paths with both forward `/` and backward `\` slashes are accepted.
624622

625623
### Syntax
626624

627-
`call [[stdlib_system(module):get_cwd(subroutine)]] (cwd, err)`
625+
`call [[stdlib_system(module):remove_directory(subroutine)]] (path, err)`
628626

629627
### Class
630628

631629
Subroutine
632630

633631
### Arguments
634632

635-
`cwd`: Shall be a character string containing the path of the current working directory (cwd). It is an `intent(out)` argument.
633+
`path`: Shall be a character string containing the path of the directory to create. It is an `intent(in)` argument.
636634

637-
`err`: Shall be of type `state_type`, for error handling. It is an `intent(out)` argument.
635+
`err`(optional): Shall be of type `state_type`, and is used for error handling. It is an `optional, intent(out)` argument.
638636

639637
### Return values
640638

641-
The `err` is set accordingly.
639+
`err` is an optional state return flag. On error if not requested, an `FS_ERROR` will trigger an error stop.
642640

643641
### Example
644642

645643
```fortran
646-
{!example/system/example_cwd.f90!}
644+
{!example/system/example_remove_directory.f90!}
647645
```
648646

649647
---
650648

651-
## `set_cwd` - Sets the current working directory
649+
## `get_cwd` - Gets the current working directory
652650

653651
### Status
654652

655653
Experimental
656654

657655
### Description
658656

659-
It sets the current working directory associated with the process calling this subroutine.
657+
It gets the current working directory associated with the process calling this subroutine.
660658
It is designed to work across multiple platforms. On Windows, paths with both forward `/` and backward `\` slashes are accepted.
661659

662660
### Syntax
663661

664-
`call [[stdlib_system(module):set_cwd(subroutine)]] (path, err)`
662+
`call [[stdlib_system(module):get_cwd(subroutine)]] (cwd, err)`
665663

666664
### Class
667665

668666
Subroutine
669667

670668
### Arguments
671669

672-
`path`: Shall be a character string containing the path of the directory. It is an `intent(in)` argument.
670+
`cwd`: Shall be a character string containing the path of the current working directory (cwd). It is an `intent(out)` argument.
673671

674672
`err`: Shall be of type `state_type`, for error handling. It is an `intent(out)` argument.
675673

@@ -685,42 +683,43 @@ The `err` is set accordingly.
685683

686684
---
687685

688-
## `null_device` - Return the null device file path
686+
## `set_cwd` - Sets the current working directory
689687

690688
### Status
691689

692690
Experimental
693691

694692
### Description
695693

696-
This function returns the file path of the null device, which is a special file used to discard any data written to it.
697-
It reads as an empty file. The null device's path varies by operating system:
698-
- On Windows, the null device is represented as `NUL`.
699-
- On UNIX-like systems (Linux, macOS), the null device is represented as `/dev/null`.
694+
It sets the current working directory associated with the process calling this subroutine.
695+
It is designed to work across multiple platforms. On Windows, paths with both forward `/` and backward `\` slashes are accepted.
700696

701697
### Syntax
702698

703-
`path = ` [[stdlib_system(module):null_device(function)]]`()`
699+
`call [[stdlib_system(module):set_cwd(subroutine)]] (path, err)`
704700

705701
### Class
706702

707-
Function
703+
Subroutine
708704

709705
### Arguments
710706

711-
None.
707+
`path`: Shall be a character string containing the path of the directory. It is an `intent(in)` argument.
712708

713-
### Return Value
709+
`err`: Shall be of type `state_type`, for error handling. It is an `intent(out)` argument.
714710

715-
- **Type:** `character(:), allocatable`
716-
- Returns the null device file path as a character string, appropriate for the operating system.
711+
### Return values
712+
713+
The `err` is set accordingly.
717714

718715
### Example
719716

720717
```fortran
721-
{!example/system/example_null_device.f90!}
718+
{!example/system/example_cwd.f90!}
722719
```
723720

721+
---
722+
724723
## `delete_file` - Delete a file
725724

726725
### Status

example/system/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ ADD_EXAMPLE(fs_error)
1818
ADD_EXAMPLE(path_join)
1919
ADD_EXAMPLE(path_split_path)
2020
ADD_EXAMPLE(path_base_name)
21-
ADD_EXAMPLE(path_dir_name)
21+
ADD_EXAMPLE(path_dir_name)
22+
ADD_EXAMPLE(make_directory)
23+
ADD_EXAMPLE(remove_directory)
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
! Illustrate the usage of make_directory
1+
! Illustrate the usage of `make_directory`, `make_directory_all`
22
program example_make_directory
3-
use stdlib_system, only: make_directory, is_directory
3+
use stdlib_system, only: make_directory, make_directory_all
44
use stdlib_error, only: state_type
55
implicit none
66

77
type(state_type) :: err
88

9-
call make_directory("test", err=err)
9+
call make_directory("temp_dir", err)
1010

1111
if (err%error()) then
1212
print *, err%print()
1313
else
1414
print *, "directory created sucessfully"
1515
end if
1616

17+
call make_directory_all("d1/d2/d3/d4", err)
18+
19+
if (err%error()) then
20+
print *, err%print()
21+
else
22+
print *, "nested directories created sucessfully"
23+
end if
24+
1725
end program example_make_directory

example/system/example_remove_directory.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
! Illustrate the usage of remove_directory
1+
! Illustrate the usage of `remove_directory`
22
program example_remove_directory
3-
use stdlib_system, only: make_directory, is_directory, remove_directory
3+
use stdlib_system, only: remove_directory
44
use stdlib_error, only: state_type
55
implicit none
66

src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ set(fppFiles
5656
stdlib_specialfunctions_gamma.fypp
5757
stdlib_specialfunctions.fypp
5858
stdlib_specialmatrices.fypp
59-
stdlib_specialmatrices_tridiagonal.fypp
59+
stdlib_specialmatrices_tridiagonal.fypp
6060
stdlib_stats.fypp
6161
stdlib_stats_corr.fypp
6262
stdlib_stats_cov.fypp
@@ -119,6 +119,7 @@ set(SRC
119119
stdlib_system_subprocess.F90
120120
stdlib_system.c
121121
stdlib_system_path.f90
122+
stdlib_system.c
122123
stdlib_system.F90
123124
stdlib_sparse.f90
124125
stdlib_specialfunctions_legendre.f90

src/stdlib_ascii.fypp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,47 +107,47 @@ module stdlib_ascii
107107
contains
108108

109109
!> Checks whether `c` is an ASCII letter (A .. Z, a .. z).
110-
pure logical function is_alpha(c)
110+
elemental logical function is_alpha(c)
111111
character(len=1), intent(in) :: c !! The character to test.
112112
is_alpha = (c >= 'A' .and. c <= 'Z') .or. (c >= 'a' .and. c <= 'z')
113113
end function
114114

115115
!> Checks whether `c` is a letter or a number (0 .. 9, a .. z, A .. Z).
116-
pure logical function is_alphanum(c)
116+
elemental logical function is_alphanum(c)
117117
character(len=1), intent(in) :: c !! The character to test.
118118
is_alphanum = (c >= '0' .and. c <= '9') .or. (c >= 'a' .and. c <= 'z') &
119119
.or. (c >= 'A' .and. c <= 'Z')
120120
end function
121121

122122
!> Checks whether or not `c` is in the ASCII character set -
123123
!> i.e. in the range 0 .. 0x7F.
124-
pure logical function is_ascii(c)
124+
elemental logical function is_ascii(c)
125125
character(len=1), intent(in) :: c !! The character to test.
126126
is_ascii = iachar(c) <= int(z'7F')
127127
end function
128128

129129
!> Checks whether `c` is a control character.
130-
pure logical function is_control(c)
130+
elemental logical function is_control(c)
131131
character(len=1), intent(in) :: c !! The character to test.
132132
integer :: ic
133133
ic = iachar(c)
134134
is_control = ic < int(z'20') .or. ic == int(z'7F')
135135
end function
136136

137137
!> Checks whether `c` is a digit (0 .. 9).
138-
pure logical function is_digit(c)
138+
elemental logical function is_digit(c)
139139
character(len=1), intent(in) :: c !! The character to test.
140140
is_digit = ('0' <= c) .and. (c <= '9')
141141
end function
142142

143143
!> Checks whether `c` is a digit in base 8 (0 .. 7).
144-
pure logical function is_octal_digit(c)
144+
elemental logical function is_octal_digit(c)
145145
character(len=1), intent(in) :: c !! The character to test.
146146
is_octal_digit = (c >= '0') .and. (c <= '7');
147147
end function
148148

149149
!> Checks whether `c` is a digit in base 16 (0 .. 9, A .. F, a .. f).
150-
pure logical function is_hex_digit(c)
150+
elemental logical function is_hex_digit(c)
151151
character(len=1), intent(in) :: c !! The character to test.
152152
is_hex_digit = (c >= '0' .and. c <= '9') .or. (c >= 'a' .and. c <= 'f') &
153153
.or. (c >= 'A' .and. c <= 'F')
@@ -156,7 +156,7 @@ contains
156156
!> Checks whether or not `c` is a punctuation character. That includes
157157
!> all ASCII characters which are not control characters, letters,
158158
!> digits, or whitespace.
159-
pure logical function is_punctuation(c)
159+
elemental logical function is_punctuation(c)
160160
character(len=1), intent(in) :: c !! The character to test.
161161
integer :: ic
162162
ic = iachar(c) ! '~' '!'
@@ -166,7 +166,7 @@ contains
166166

167167
!> Checks whether or not `c` is a printable character other than the
168168
!> space character.
169-
pure logical function is_graphical(c)
169+
elemental logical function is_graphical(c)
170170
character(len=1), intent(in) :: c !! The character to test.
171171
integer :: ic
172172
ic = iachar(c)
@@ -177,7 +177,7 @@ contains
177177

178178
!> Checks whether or not `c` is a printable character - including the
179179
!> space character.
180-
pure logical function is_printable(c)
180+
elemental logical function is_printable(c)
181181
character(len=1), intent(in) :: c !! The character to test.
182182
integer :: ic
183183
ic = iachar(c)
@@ -186,23 +186,23 @@ contains
186186
end function
187187

188188
!> Checks whether `c` is a lowercase ASCII letter (a .. z).
189-
pure logical function is_lower(c)
189+
elemental logical function is_lower(c)
190190
character(len=1), intent(in) :: c !! The character to test.
191191
integer :: ic
192192
ic = iachar(c)
193193
is_lower = ic >= iachar('a') .and. ic <= iachar('z')
194194
end function
195195

196196
!> Checks whether `c` is an uppercase ASCII letter (A .. Z).
197-
pure logical function is_upper(c)
197+
elemental logical function is_upper(c)
198198
character(len=1), intent(in) :: c !! The character to test.
199199
is_upper = (c >= 'A') .and. (c <= 'Z')
200200
end function
201201

202202
!> Checks whether or not `c` is a whitespace character. That includes the
203203
!> space, tab, vertical tab, form feed, carriage return, and linefeed
204204
!> characters.
205-
pure logical function is_white(c)
205+
elemental logical function is_white(c)
206206
character(len=1), intent(in) :: c !! The character to test.
207207
integer :: ic
208208
ic = iachar(c) ! TAB, LF, VT, FF, CR
@@ -211,7 +211,7 @@ contains
211211

212212
!> Checks whether or not `c` is a blank character. That includes the
213213
!> only the space and tab characters
214-
pure logical function is_blank(c)
214+
elemental logical function is_blank(c)
215215
character(len=1), intent(in) :: c !! The character to test.
216216
integer :: ic
217217
ic = iachar(c) ! TAB

0 commit comments

Comments
 (0)