Jump to content

Check that file exists: Difference between revisions

Add NetRexx implementation
(→‎{{header|REXX}}: fixed case of directory)
(Add NetRexx implementation)
Line 719:
IO.Put(Fmt.Bool(FileExists("/docs")) & "\n");
END FileTest.</lang>
 
=={{header|NetRexx}}==
<lang NetRexx>/* NetRexx */
options replace format comments java crossref symbols binary
 
runSample(arg)
return
 
-- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
method isExistingFile(fn) public static returns boolean
ff = File(fn)
fExists = ff.exists() & ff.isFile()
return fExists
 
-- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
method isExistingDirectory(fn) public static returns boolean
ff = File(fn)
fExists = ff.exists() & ff.isDirectory()
return fExists
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg files
if files = '' then files = 'input.txt F docs D /input.txt F /docs D'
loop while files.length > 0
parse files fn ft files
select case(ft.upper())
when 'F' then do
if isExistingFile(fn) then ex = 'exists'
else ex = 'does not exist'
say 'File '''fn'''' ex
end
when 'D' then do
if isExistingDirectory(fn) then ex = 'exists'
else ex = 'does not exist'
say 'Directory '''fn'''' ex
end
otherwise do
if isExistingFile(fn) then ex = 'exists'
else ex = 'does not exist'
say 'File '''fn'''' ex
end
end
end
 
return
</lang>
 
=={{header|Objective-C}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.