Skip to content

CCFileUtils-win32::isFileExistInternal fails on a directory, while CCFileUtils-linux's doesn't #19058

@tankorsmash

Description

@tankorsmash

Windows:

if(attr == INVALID_FILE_ATTRIBUTES || (attr & FILE_ATTRIBUTE_DIRECTORY))

Linux:

return (stat(strPath.c_str(), &sts) != -1) ? true : false;

The C++ file to test the result of stat on linux, result is 0 on a dir that exists:

#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <iostream>

int main()
{
	struct stat sts;
	auto result = stat("a dir that exists on your machine/", &sts);
	std::cout << "result is: " << result;
	return 0;
};

whereas attr = GetFileAttributesW("a dir that exists") does result in attr & FILE_ATTRIBUTE_DIRECTORY being non-zero.

This seems to mean CCFileUtilsWin32::listFiles can't work, because https://github.com/cocos2d/cocos2d-x/blob/v3/cocos/platform/win32/CCFileUtils-win32.cpp#L276 will always return "", since it ends up going down to CCFileUtils-win32::isFileExistInternal and failing.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions