How to resolve the algorithm Check that file exists step by step in the ooRexx programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Check that file exists step by step in the ooRexx programming language

Table of Contents

Problem Statement

Verify that a file called     input.txt     and   a directory called     docs     exist.

This should be done twice:

Optional criteria (May 2015):   verify it works with:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Check that file exists step by step in the ooRexx programming language

Source code in the oorexx programming language

/**********************************************************************
* exists(filespec)
* returns 1   if filespec identifies a file with size>0
*                (a file of size 0 is deemed not to exist.)
*             or a directory
*         0   otherwise
* 09.06.2013 Walter Pachl (retrieved from my toolset)
**********************************************************************/
exists:
  parse arg spec
  call sysfiletree spec, 'LIST', 'BL'
  if list.0\=1 then return 0        -- does not exist
  parse var list.1 . . size flags .
  if size>0 then return 1           -- real file
  If substr(flags,2,1)='D' Then Do
    Say spec 'is a directory'
    Return 1
    End
  If size=0 Then Say spec 'is a zero-size file'
  Return 0

  

You may also check:How to resolve the algorithm Dijkstra's algorithm step by step in the Arturo programming language
You may also check:How to resolve the algorithm State name puzzle step by step in the Ruby programming language
You may also check:How to resolve the algorithm Happy numbers step by step in the Oz programming language
You may also check:How to resolve the algorithm Modular inverse step by step in the Ring programming language
You may also check:How to resolve the algorithm Almost prime step by step in the Draco programming language