Starting with a path to some directory, determine whether the directory is empty.

An empty directory contains no files nor subdirectories.
With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other entries.

without js -- file i/o
procedure test(string filename)
    string msg
    switch get_file_type(filename) do
        case FILETYPE_UNDEFINED: msg = "is UNDEFINED"
        case FILETYPE_NOT_FOUND: msg = "is NOT_FOUND"
        case FILETYPE_FILE:      msg = "is a FILE"
        case FILETYPE_DIRECTORY:
            integer count = length(filter(vslice(dir(filename),D_NAME),"out",{".",".."}))
            msg = iff(count=0?"is an empty directory"
                             :sprintf("is a directory containing %d files",{count}))
    end switch
    printf(1,"%s %s\n",{filename,msg})
end procedure
 
constant tests = {"C:\\xx","C:\\not_there","C:\\Program Files (x86)\\Phix\\p.exe","C:\\Windows"}
for i=1 to length(tests) do
    test(tests[i])
end for
