File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,4 @@ ADD_EXAMPLE(path_base_name)
18
18
ADD_EXAMPLE (path_dir_name )
19
19
ADD_EXAMPLE (make_directory )
20
20
ADD_EXAMPLE (remove_directory )
21
+ ADD_EXAMPLE (cwd )
Original file line number Diff line number Diff line change
1
+ ! Illustrate the usage of get_cwd, set_cwd
2
+ program example_cwd
3
+ use stdlib_system, only: get_cwd, set_cwd
4
+ use stdlib_error, only: state_type
5
+ implicit none
6
+
7
+ character (len= :), allocatable :: path
8
+ type (state_type) :: err
9
+
10
+ call get_cwd(path, err)
11
+
12
+ if (err% error()) then
13
+ print * , " Error getting current working directory: " // err% print ()
14
+ end if
15
+
16
+ print * , " CWD: " // path
17
+
18
+ call set_cwd(" ./src" , err)
19
+
20
+ if (err% error()) then
21
+ print * , " Error setting current working directory: " // err% print ()
22
+ end if
23
+
24
+ call get_cwd(path, err)
25
+
26
+ if (err% error()) then
27
+ print * , " Error getting current working directory after using set_cwd: " // err% print ()
28
+ return
29
+ end if
30
+
31
+ print * , " CWD: " // path
32
+ end program example_cwd
33
+
You can’t perform that action at this time.
0 commit comments