
Martin wrote:
If I write *.txt in a windows file selection dialog box, I will see all files in the directory ending with ".txt" (in lowercase) but also all files ending in ".TXT", ".tXt" etc that doesn't have the FILE_FLAG_POSIX_SEMANTICS attribute set.
I get the same result by using "*.txt" with the win32 native functions FindFirstFile/FindNextFile.
Ok, understood. Thanks.
It is normally not a problem but when trying to write portable code it is not clear if I should write "*.txt" or "*.[tT][xX][tT]". Both might give non- expected results.
The best thing would be if the glob function treated case sensitivity in the same way as the underlying filsystem but then it would have to be part of the filesystem library.
I think so too. However, the problem becomes "Design an interface to glob so that I can pass flags to the underlying filesystem::directory_iterator". Assuming that this is the solution that Beman adopts. Perhaps you should direct your problem towards him in the first instance.
Another thing: The boost.filesystem function is_directory might throw for security reasons on files in a directory. I recommend that you create your own non-throwing overload
bool is_directory(const path& aPath, bool aErrorRet) { try { return is_directory(aPath); } catch (...) { return aErrorRet; } }
Good. Thanks. Actually I think I'll just use: bool nothrow_is_directory(filesystem::path const & path) { try { return is_directory(path); } catch (filesystem::filesystem_error const &) { return false; } } Since the function description talks explicitly about the permissions needed to find a match. I guess that I'll need to wrap "exists(path)" too. Will have a look. Regards, Angus