Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cocos/platform/win32/CCFileUtils-win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ THE SOFTWARE.
#include <regex>
#include <sstream>

#include <sys/types.h>
#include <sys/stat.h>

using namespace std;

#define DECLARE_GUARD std::lock_guard<std::recursive_mutex> mutexGuard(_mutex)
Expand Down Expand Up @@ -271,6 +274,16 @@ void FileUtilsWin32::listFilesRecursively(const std::string& dirPath, std::vecto
}
}

long FileUtilsWin32::getFileSize(const std::string &filepath) const
{
struct _stat tmp;
if (_stat(filepath.c_str(), &tmp) == 0)
{
return (long)tmp.st_size;
}
return 0;
}

std::vector<std::string> FileUtilsWin32::listFiles(const std::string& dirPath) const
{
std::string fullpath = fullPathForFilename(dirPath);
Expand Down
2 changes: 2 additions & 0 deletions cocos/platform/win32/CCFileUtils-win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class CC_DLL FileUtilsWin32 : public FileUtils

virtual FileUtils::Status getContents(const std::string& filename, ResizableBuffer* buffer) const override;

virtual long getFileSize(const std::string &filepath) const override;

/**
* Gets full path for filename, resolution directory and search path.
*
Expand Down