! Test pentru:
! getdirivedirqq (dflib)
! GetCurentDirectory (dfwin)
! + inapoi cu un nivel

use dflib
use dfwin

character($maxpath) cur_dir, up_dir
character(max_path) cur2_dir, up2_dir

! DFLIB:
cur_dir =FILE$CURDRIVE
i  = getdrivedirqq(cur_dir)

open(1, file='GetDir.rez', status='unknown', form='formatted')

print*, trim(cur_dir)
write(1,'(a)') 'getdirvedirqq: '
write(1,'(a)') 'Curent Directory:', trim(cur_dir)

! Seek for the last backslash:
iback =Scan(cur_dir, '\', .true.)
! Move 1 level up:
up_dir =cur_dir(1:iback)
print*, trim(up_dir)
write(1,'(a)') 'Up Directory:', trim(up_dir)

! SDK:
! len2 =no. of. chars - not including the null terminating char.
len2 =GetCurrentDirectory(max_path, cur2_dir)
print*
print*, cur2_dir(1:len2)
write(1,'(/, a)') 'GetCurrentDirectory: '
write(1,'(a)') 'Curent Directory:', cur2_dir(1:len2)

! Move 1 level up:
iback2 =Scan(cur2_dir, '\', .true.)
up2_dir =cur2_dir(1:iback2)
len_up2 =lstrlen(cur2_dir)
print*, up2_dir(1:len_up2)
write(1,'(a)') 'Up Directory:', up2_dir(1:len_up2)

close(1)
END
