mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-15 23:40:29 +02:00
The libretro core is the frontend, and the headless tools are the test and debugging hosts. The Windows, UWP, Android, iOS, macOS and SDL apps, the UI framework and imgui go, along with what only they used: the Win32 debugger hooks (g_frameMutex, the shutdown lock), JNI thread attachment, the Android text drawer, RAIntegration, Discord, recent files, game installs, tilt input, the audio resamplers, the control mapper, memstick moving and the remote ISO and upload server modes. The web server keeps the debugger. The MSVC, Gradle and ndk-build projects go too.
61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
#ifdef _WIN32
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#include "Common/CommonWindows.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 <cinttypes>
|
|
|
|
#include "Common/Log.h"
|
|
#include "Common/File/Path.h"
|
|
#include "Common/File/AndroidStorage.h"
|
|
#include "Common/Data/Encoding/Utf8.h"
|
|
#include "Common/TimeUtil.h"
|
|
|
|
bool free_disk_space(const Path &path, int64_t &space) {
|
|
#ifdef _WIN32
|
|
ULARGE_INTEGER free;
|
|
if (GetDiskFreeSpaceExW(path.ToWString().c_str(), &free, nullptr, nullptr)) {
|
|
space = free.QuadPart;
|
|
return true;
|
|
}
|
|
#else
|
|
if (path.Type() == PathType::CONTENT_URI) {
|
|
space = Android_GetFreeSpaceByContentUri(path.ToString());
|
|
INFO_LOG(Log::Common, "Free space at '%s': %" PRIu64, path.c_str(), space);
|
|
return space >= 0;
|
|
}
|
|
|
|
struct statvfs diskstat;
|
|
int res = statvfs(path.c_str(), &diskstat);
|
|
|
|
if (res == 0) {
|
|
// Not sure why we're excluding Android here anyway...
|
|
#ifndef __ANDROID__
|
|
if (diskstat.f_flag & ST_RDONLY) {
|
|
// No space to write.
|
|
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;
|
|
}
|