mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
9e41fafd0d
Buildfixing Move some file util files Buildfix Move KeyMap.cpp/h to Core where they belong better. libretro buildfix attempt Move ini_file More buildfixes
49 lines
979 B
C++
49 lines
979 B
C++
#ifdef _WIN32
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#include <Windows.h>
|
|
#include <sys/stat.h>
|
|
#else
|
|
#include <dirent.h>
|
|
#include <unistd.h>
|
|
#include <sys/stat.h>
|
|
#if defined(__ANDROID__)
|
|
#include <sys/types.h>
|
|
#include <sys/vfs.h>
|
|
#define statvfs statfs
|
|
#else
|
|
#include <sys/statvfs.h>
|
|
#endif
|
|
#include <ctype.h>
|
|
#include <fcntl.h>
|
|
#endif
|
|
|
|
#include "Common/Data/Encoding/Utf8.h"
|
|
|
|
bool free_disk_space(const std::string &dir, uint64_t &space) {
|
|
#ifdef _WIN32
|
|
const std::wstring w32path = ConvertUTF8ToWString(dir);
|
|
ULARGE_INTEGER free;
|
|
if (GetDiskFreeSpaceExW(w32path.c_str(), &free, nullptr, nullptr)) {
|
|
space = free.QuadPart;
|
|
return true;
|
|
}
|
|
#else
|
|
struct statvfs diskstat;
|
|
int res = statvfs(dir.c_str(), &diskstat);
|
|
|
|
if (res == 0) {
|
|
#ifndef __ANDROID__
|
|
if (diskstat.f_flag & ST_RDONLY) {
|
|
space = 0;
|
|
return true;
|
|
}
|
|
#endif
|
|
space = (uint64_t)diskstat.f_bavail * (uint64_t)diskstat.f_frsize;
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
// We can't know how much is free.
|
|
return false;
|
|
}
|