Check that file exists: Difference between revisions

Content added Content deleted
m (→‎{{header|Fortran}}: nl ww; lang tag; comments' maquillage + comment notes; - ;)
Line 172: Line 172:
=={{header|Fortran}}==
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
{{works with|Fortran|90 and later}}
Cannot check for directories in Fortran
LOGICAL :: file_exists
INQUIRE(FILE="input.txt", EXIST=file_exists) ! file_exists will be TRUE if the file exists and FALSE otherwise
INQUIRE(FILE="/input.txt", EXIST=file_exists)


Cannot check for directories in Fortran
<lang fortran> LOGICAL :: file_exists
INQUIRE(FILE="input.txt", EXIST=file_exists) ! file_exists will be TRUE if the file
! exists and FALSE otherwise
INQUIRE(FILE="/input.txt", EXIST=file_exists)</lang>


Acutally, f90,f95 are able to deal with directory staff:
Actually, f90,f95 are able to deal with directory staff:


logical:: dir_e;
<lang fortran> logical :: dir_e
! a trick to be sure docs is a dir
inquire( file="./docs/.", exist=dir_e );
if( dir_e ) then
inquire( file="./docs/.", exist=dir_e )
if ( dir_e ) then
write(*,*), "dir exists!";
write(*,*), "dir exists!"
else
else
! workaround: it calls an extern program...
call system('mkdir docs');
call system('mkdir docs')
end if
end if</lang>


=={{header|Haskell}}==
=={{header|Haskell}}==