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  


without js -- (file i/o)
procedure check(string name)
    bool bExists = file_exists(name),
         bDir = get_file_type(name)=FILETYPE_DIRECTORY
    string exists = iff(bExists?"exists":"does not exist"),
           dfs = iff(bExists?iff(bDir?"directory ":"file "):"")
    printf(1,"%s%s %s.\n",{dfs,name,exists})
end procedure
 
check("input.txt")
check("docs")
check("/input.txt")
check("/docs")
check("/pagefile.sys")
check("/Program Files (x86)")
