OutpostUniverse / OP2Utility

C++ library for working with Outpost 2 related files and tasks.
MIT License
4 stars 0 forks source link

Should XFile::GetFilesFromDirectory return full paths or only filenames #252

Closed Brett208 closed 5 years ago

Brett208 commented 5 years ago

Based on use case in OP2MapImager, it would be better if this function returned the filename only and not the full path. IE if passed the directory C://test, just return ashes.map instead of C://test/ashes.map.

Maybe better if we rename the function GetFilenamesFromDirectory to be more specific in what it does.

DanRStevens commented 5 years ago

I agree. Usually I want relative paths. Plus, it's really easy to turn a relative path into an absolute path if you know the base folder it came from (which is usually the parameter to this method).

To extend the idea a bit further, consider the case of the recursive directory iterator. In that case, you may still get path components as part of the filename, for files in nested folders. In both the non-recursive and the recursive case, you can say the filenames are relative to the base search folder.

Example:

A/file1.ext
A/B/file2.ext
GetFilesnamesFromDirectory("A/"); // => ["file1.ext"]
GetFilesnamesFromDirectoryRecursive("A/"); // => ["file1.ext", "B/file2.ext"]

Paths are relative to the search folder.

Brett208 commented 5 years ago

Ok, I'm going to implement this minus the recursive directory search. No need for that feature for this release.

Thanks for the quick feedback.