I have problems with the proposed solutions. (Sorry to butt in, I was
working on another File::BaseDir ticket)
There's really two ideas here. The first is to smash together file and
directory searching. Files and directories are generally treated as
different things in your code. It's unlikely that you want to do the
same thing with a file and a directory, especially a data directory vs a
data file. Thus having one function to search for both seems odd.
The proposed solutions to this complicate the interface. "resource" is
a terribly generic term and doesn't really suggest "file or directory"
but "anything". Maybe a database, a socket, a display device? It also
leads to ambiguities, did you mean to search for a file or a directory?
No way to tell. So that's right out.
By making xdg_data_files() search for directories, or vice versa, is
also bad. It means the name lies. "xdg_data_files" is going to have
you data files, not directories. The proper name for this function
would be "xdg_data_files_and_directories". A contraction in a function
name is a screaming red flag that the function is trying to do much.
This complicates the code, documentation and user understanding of the
function. For the ultimate example of this, see the "find" program.
But smashing the file and directory functionality together doesn't seem
to be the real user desire. It's not actually a problem but an
attempted solution at the real problem...
The real user desire here is to have xdg_data_dirs() search for a
directory under it's data dirs, and that seems valid enough. You can
add an argument to xdg_data_dirs() and all is well. The function names
still reflect what they do, there's no smashing together of disparate
functionality, no special flags to pass in. Even better, the two
functions now work more like each other than before.