fs: Drop filesystem::init() and Windows XP-specific code in it

The function's only purpose so far is to initialize a function pointer
to a kernel32.dll export (GetFinalPathNameByHandleW) that isn't present
on versions before Windows Vista. However, this development branch
explicitly bumps the minimum build target to Windows 7, rendering the
code redundant.

This also gets rid of a rather bothersome GCC warning involving the
FARPROC pointer cast used to store the result of GetProcAddress().
This commit is contained in:
Iris Morelle 2019-09-24 06:44:46 -03:00
parent c7271646b7
commit ca71057e7f
3 changed files with 1 additions and 23 deletions

View file

@ -211,18 +211,10 @@ public:
static static_runner static_bfs_path_imbuer;
typedef DWORD(WINAPI* GetFinalPathNameByHandleWPtr)(HANDLE, LPWSTR, DWORD, DWORD);
static GetFinalPathNameByHandleWPtr dyn_GetFinalPathNameByHandle;
bool is_filename_case_correct(const std::string& fname, const boost::iostreams::file_descriptor_source& fd)
{
if(dyn_GetFinalPathNameByHandle == nullptr) {
// Windows XP. Just assume that the case is correct.
return true;
}
wchar_t real_path[MAX_PATH];
dyn_GetFinalPathNameByHandle(fd.handle(), real_path, MAX_PATH - 1, VOLUME_NAME_NONE);
GetFinalPathNameByHandleW(fd.handle(), real_path, MAX_PATH - 1, VOLUME_NAME_NONE);
std::string real_name = filesystem::base_name(unicode_cast<std::string>(std::wstring(real_path)));
return real_name == filesystem::base_name(fname);
@ -238,15 +230,6 @@ bool is_filename_case_correct(const std::string& /*fname*/, const boost::iostrea
namespace filesystem
{
void init()
{
#ifdef _WIN32
HMODULE kernel32 = GetModuleHandle(TEXT("Kernel32.dll"));
// Note that this returns a null pointer on Windows XP!
dyn_GetFinalPathNameByHandle
= reinterpret_cast<GetFinalPathNameByHandleWPtr>(GetProcAddress(kernel32, "GetFinalPathNameByHandleW"));
#endif
}
static void push_if_exists(std::vector<std::string>* vec, const bfs::path& file, bool full)
{

View file

@ -130,9 +130,6 @@ static const blacklist_pattern_list default_blacklist{
}
};
/** Some tasks to run on startup. */
void init();
/**
* Populates 'files' with all the files and
* 'dirs' with all the directories in dir.

View file

@ -1092,8 +1092,6 @@ int main(int argc, char** argv)
assert(!args.empty());
filesystem::init();
if(SDL_Init(SDL_INIT_TIMER) < 0) {
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);