Task

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



This should be done twice:  

   once for the current working directory,   and
   once for a file and a directory in the filesystem root.


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

   zero-length files
   an unusual filename:     `Abdu'l-Bahá.txt  


include file.e
 
procedure ensure_exists(sequence name)
    object x
    sequence s
    x = dir(name)
    if sequence(x) then
        if find('d',x[1][D_ATTRIBUTES]) then
            s = "directory"
        else
            s = "file"
        end if
        printf(1,"%s %s exists.\n",{name,s})
    else
        printf(1,"%s does not exist.\n",{name})
    end if
end procedure
 
ensure_exists("input.txt")
ensure_exists("docs")
ensure_exists("/input.txt")
ensure_exists("/docs")