Welcome Guest, Not a member yet? Register   Sign In
get_filenames() behavior
#1

The Filesystem helper defines the get_filenames($source_dir[, $include_path = FALSE]) function, described in the User Guide:

Quote:Takes a server path as input and returns an array containing the names of all files contained within it. The file path can optionally be added to the file names by setting the second parameter to TRUE.


The function has two different return types contingent on its second parameter. The first (default) is a flat list of all files in all subdirectories:
Code:
document.txt
cat.jpg
rainbow.exe

And the second is the same files by their absolute paths:
Code:
/var/www/html/mysite/document.txt
/var/www/html/mysite/assets/cat.jpg
/var/www/html/mysite/downloads/cached/rainbow.exe

My question to you all: why would the first return type ever be useful? I keep coming back to this function forgetting its "flattening" effect and being disappointed that I can't get the relative paths:
Code:
document.txt
assets/cat.jpg
downloads/cached/rainbow.exe

The default return case is never used in the framework itself, and my opinion is that it should return the relative path instead of just the filename. With the relative path it would still be easy to acquire the flat filename, e.g. with pathinfo() and array_map().

Anyone with experience of the Filesystem helper have input?
Reply


Messages In This Thread
get_filenames() behavior - by MGatner - 03-27-2020, 05:46 PM
RE: get_filenames() behavior - by jreklund - 03-28-2020, 01:38 AM
RE: get_filenames() behavior - by John_Betong - 03-28-2020, 10:02 PM
RE: get_filenames() behavior - by MGatner - 03-29-2020, 06:28 AM
RE: get_filenames() behavior - by dave friend - 03-30-2020, 08:00 AM
RE: get_filenames() behavior - by MGatner - 03-30-2020, 08:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB