Fabian Maurer dark.shadow4@web.de writes:
HANDLE input;DWORD attributes = GetFileAttributesW(file_paths[i]);WCHAR file_path_upper[MAX_PATH];wcscpy(file_path_upper, file_paths[i]);CharUpperW(file_path_upper);if (attributes == INVALID_FILE_ATTRIBUTES || (attributes & FILE_ATTRIBUTE_DIRECTORY)){WCHAR buffer_message[64];WCHAR message[300];LoadStringW(GetModuleHandleW(NULL), IDS_FILE_NOT_FOUND, buffer_message, ARRAY_SIZE(buffer_message));wsprintfW(message, buffer_message, file_path_upper);write_to_stdout(message);continue;}input = CreateFileW(file_paths[i], GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);if (!input){ERR("Failed to open file %ls\n", file_paths[i]);continue;}
Again, there's no reason to check the attributes first. Just try to open the file and handle the failure.