[forther] checking file and folder existence

mhx at iae.nl mhx at iae.nl
Wed Jun 10 01:55:01 PDT 2020


On 2020-06-10 08:45, rt4all at hetnet.nl wrote:
> Hi all,
> 
> Are there iForth versions for
> SwiftForth  IS-DIR ( z-addr -- flag )   and  IS-FILE ( z-addr -- flag )
> or VFX  dirExists?	\ caddr len -- flag    and   FileExist?    \ caddr
> len -- flag
> 
> I need to check the existence of nib files just prior to an attempt 
> showing them
> on the screen in macOS coco-i4 SHOW.NIB

FORTH> words: file
LIST-OPEN-FILES       ?FILE$                ?FILE                 
CURRENT-FILE:         SLURP-FILE(3)         SLURP-FILE(2)         
SLURP-FILE(1)         SLURP-FILE
FILE-BIRTH            FILE-TIME             FILE-EXISTS?          
FILE-HERE             ONLY-BASEFILENAME     ONLY-FILENAME         
CURRENT-FILE=         FILE-I//O
INCLUDE-FILE          FILE-SIZE             FILE-POSITION         
REPOSITION-FILE       RESIZE-FILE           FLUSH-FILE            
WRITE-FILE            READ-FILE
SEEK-FILE             CLOSE-FILE            OPEN-FILE             
FILE-STATUS           RENAME-FILE           DELETE-FILE           
CREATE-FILE           MAP-FILE
SOURCEFILENAME        ?FILE                 logfile
  ok
FORTH> help file-status
FILE-STATUS                                                        FILE 
EXT
      ( c-addr u -- x ior )
      Return the status of the file/directory identified by the character
      string (c-addr u). The ior is zero if the file/directory exists and
      writing to it is possible; otherwise <ior> is TRUE.
      x contains implementation-defined information about the file.
      In iForth x is a bitmask giving more details,
        $0001 - set when a regular file was tested.
        $0002 - set when a directory was tested
        $0100 - set when reading from file/directory is possible
        $0200 - set when writing to file/directory is possible
      All other bits are reserved and cleared.
  ok
FORTH>

-marcel


More information about the forther mailing list