File: example_cwd.f90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (32 lines) | stat: -rw-r--r-- 777 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
! Illustrate the usage of `get_cwd`, `set_cwd`
program example_cwd
    use stdlib_system, only: get_cwd, set_cwd
    use stdlib_error, only: state_type
    implicit none 

    character(len=:), allocatable :: path
    type(state_type) :: err

    call get_cwd(path, err)

    if (err%error()) then
        print *, "Error getting current working directory: "//err%print()
    end if
    
    print *, "CWD: "//path

    call set_cwd("./src", err)

    if (err%error()) then
        print *, "Error setting current working directory: "//err%print()
    end if

    call get_cwd(path, err)

    if (err%error()) then
        print *, "Error getting current working directory after using set_cwd: "//err%print()
    end if
    
    print *, "CWD: "//path
end program example_cwd