Skip to content

Commit 866fddb

Browse files
committed
added examples
1 parent 8510867 commit 866fddb

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

example/system/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ ADD_EXAMPLE(path_base_name)
1818
ADD_EXAMPLE(path_dir_name)
1919
ADD_EXAMPLE(make_directory)
2020
ADD_EXAMPLE(remove_directory)
21+
ADD_EXAMPLE(exists)

example/system/example_exists.f90

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
! Illustrate the usage of `exists`
2+
program example_exists
3+
use stdlib_system, only: exists, type_unknown, type_regular_file, &
4+
type_directory, type_symlink
5+
use stdlib_error, only: state_type
6+
implicit none
7+
8+
type(state_type) :: err
9+
10+
character(*), parameter :: path = "path"
11+
integer :: t
12+
13+
t = exists(path, err)
14+
15+
if (err%error()) then
16+
print *, err%print()
17+
end if
18+
19+
select case (t)
20+
case (type_unknown); print *, "Unknown type!"
21+
case (type_regular_file); print *, "Regular File!"
22+
case (type_directory); print *, "Directory!"
23+
case (type_symlink); print *, "Symbolic Link!"
24+
end select
25+
end program example_exists
26+

0 commit comments

Comments
 (0)