mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-31 22:55:44 +00:00
FileUtils code moved. Refactor eventually
This commit is contained in:
parent
f636d84302
commit
89275f3126
7 changed files with 78 additions and 14 deletions
6
Externals/Slippi/SlippiGame.cpp
vendored
6
Externals/Slippi/SlippiGame.cpp
vendored
|
@ -1,7 +1,7 @@
|
|||
#include "SlippiGame.h"
|
||||
|
||||
namespace Slippi {
|
||||
// TODO: maybe refactor with std::byte and std::filesystem
|
||||
// SLIPPITODO: maybe refactor with std::byte and std::filesystem
|
||||
|
||||
//**********************************************************************
|
||||
//* Event Handlers *
|
||||
|
@ -526,8 +526,8 @@ namespace Slippi {
|
|||
#ifdef _WIN32
|
||||
// On Windows, we need to convert paths to std::wstring to deal with UTF-8
|
||||
|
||||
// TODO: codecvt is deprecated. C++17 msvc support std::filesystem::u8path
|
||||
// TODO: c++20 std::filesystem::path natively supports utf8
|
||||
// SLIPPITODO: codecvt is deprecated. C++17 msvc support std::filesystem::u8path
|
||||
// SLIPPITODO: c++20 std::filesystem::path natively supports utf8
|
||||
std::wstring convertedPath = std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(path);
|
||||
result->file = std::make_unique<std::ifstream>(convertedPath, std::ios::in | std::ios::binary);
|
||||
#else
|
||||
|
|
12
Readme.md
12
Readme.md
|
@ -15,7 +15,7 @@ Please read the [FAQ](https://dolphin-emu.org/docs/faq/) before using Dolphin.
|
|||
* OS
|
||||
* Windows (7 SP1 or higher).
|
||||
* Linux.
|
||||
* macOS (10.12 Sierra or higher).
|
||||
* macOS (10.12 Sierra or higher). // TODO: figure this out
|
||||
* Unix-like systems other than Linux are not officially supported but might work.
|
||||
* Processor
|
||||
* A CPU with SSE2 support.
|
||||
|
@ -38,9 +38,9 @@ Dolphin can only be installed on devices that satisfy the above requirements. At
|
|||
|
||||
## Building for Windows
|
||||
|
||||
Use the solution file `Source/dolphin-emu.sln` to build Dolphin on Windows.
|
||||
Visual Studio 2019 16.3 or later is a hard requirement. Other compilers might be
|
||||
able to build Dolphin on Windows but have not been tested and are not
|
||||
Visual Studio 2019 16.3 or later is a hard requirement.
|
||||
Open the folder that contains the base CMakeLists.txt file to build Dolphin on Windows.
|
||||
Other compilers might able to build Dolphin on Windows but have not been tested and are not
|
||||
recommended to be used. Git and Windows 10 SDK must be installed when building.
|
||||
|
||||
Make sure to pull submodules before building:
|
||||
|
@ -90,7 +90,7 @@ Useful for development as root access is not required.
|
|||
2. `cd Build`
|
||||
3. `cmake .. -DLINUX_LOCAL_DEV=true`
|
||||
4. `make`
|
||||
5. `ln -s ../../Data/Sys Binaries/`
|
||||
5. `ln -s ../../Overwrite/{Sys,User} Binaries/`
|
||||
|
||||
### Linux Portable Build Steps:
|
||||
|
||||
|
@ -101,7 +101,7 @@ Or useful for having multiple distinct Dolphin setups for testing/development/TA
|
|||
2. `cd Build`
|
||||
3. `cmake .. -DLINUX_LOCAL_DEV=true`
|
||||
4. `make`
|
||||
5. `cp -r ../Data/Sys/ Binaries/`
|
||||
5. `cp -r ../Overwrite/{Sys,User} Binaries/`
|
||||
6. `touch Binaries/portable.txt`
|
||||
|
||||
## Building for Android
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#define NOMEDIA_FILE ".nomedia"
|
||||
#else
|
||||
#define USERDATA_DIR "user"
|
||||
#define DOLPHIN_DATA_DIR "dolphin-emu"
|
||||
#define DOLPHIN_DATA_DIR "SlippiOnline"
|
||||
#endif
|
||||
|
||||
// Dirs in both User and Sys
|
||||
|
|
|
@ -10,6 +10,9 @@ namespace ENetUtil
|
|||
{
|
||||
void WakeupThread(ENetHost* host)
|
||||
{
|
||||
if (!host)
|
||||
return;
|
||||
|
||||
// Send ourselves a spurious message. This is hackier than it should be.
|
||||
// comex reported this as https://github.com/lsalzman/enet/issues/23, so
|
||||
// hopefully there will be a better way to do it in the future.
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <io.h>
|
||||
#include <objbase.h> // guid stuff
|
||||
#include <shellapi.h>
|
||||
#include <ShlObj.h>
|
||||
#include <winerror.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
@ -531,6 +533,28 @@ bool DeleteDirRecursively(const std::string& directory)
|
|||
return success;
|
||||
}
|
||||
|
||||
// SLIPPITODO: replace with C++17 https://en.cppreference.com/w/cpp/filesystem/last_write_time
|
||||
u64 GetFileModTime(const std::string& filename)
|
||||
{
|
||||
struct stat file_info;
|
||||
|
||||
std::string copy(filename);
|
||||
StripTailDirSlashes(copy);
|
||||
|
||||
#ifdef _WIN32
|
||||
int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info);
|
||||
#else
|
||||
int result = stat(copy.c_str(), &file_info);
|
||||
#endif
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return file_info.st_mtime;
|
||||
}
|
||||
|
||||
// Create directory and copy contents (does not overwrite existing files)
|
||||
void CopyDir(const std::string& source_path, const std::string& dest_path, bool destructive)
|
||||
{
|
||||
|
@ -709,6 +733,32 @@ std::string GetExePath()
|
|||
return dolphin_path;
|
||||
}
|
||||
|
||||
// SLIPPITODO: refactor with c++17 std::filesystem?
|
||||
std::string GetHomeDirectory()
|
||||
{
|
||||
std::string homeDir;
|
||||
#ifdef _WIN32
|
||||
wchar_t* path = nullptr;
|
||||
|
||||
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Documents, 0, nullptr, &path))) {
|
||||
char pathStr[MAX_PATH];
|
||||
wcstombs(pathStr, path, MAX_PATH);
|
||||
|
||||
homeDir = std::string(pathStr);
|
||||
CoTaskMemFree(path);
|
||||
}
|
||||
else {
|
||||
const char* home = getenv("USERPROFILE");
|
||||
homeDir = std::string(home) + "\\Documents";
|
||||
}
|
||||
#else
|
||||
const char* home = getenv("HOME");
|
||||
homeDir = std::string(home);
|
||||
#endif
|
||||
|
||||
return homeDir;
|
||||
}
|
||||
|
||||
std::string GetExeDirectory()
|
||||
{
|
||||
std::string exe_path = GetExePath();
|
||||
|
@ -736,16 +786,22 @@ std::string GetSysDirectory()
|
|||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
sysDir = GetBundleDirectory() + DIR_SEP + SYSDATA_DIR;
|
||||
sysDir = GetBundleDirectory() + DIR_SEP + SYSDATA_DIR + DIR_SEP;
|
||||
#elif defined(_WIN32) || defined(LINUX_LOCAL_DEV)
|
||||
sysDir = GetExeDirectory() + DIR_SEP + SYSDATA_DIR;
|
||||
sysDir = GetExeDirectory() + DIR_SEP + SYSDATA_DIR + DIR_SEP;
|
||||
#elif defined ANDROID
|
||||
sysDir = s_android_sys_directory;
|
||||
ASSERT_MSG(COMMON, !sysDir.empty(), "Sys directory has not been set");
|
||||
#else
|
||||
sysDir = SYSDATA_DIR;
|
||||
const char* home = getenv("HOME");
|
||||
if (!home) home = getenv("PWD");
|
||||
if (!home) home = "";
|
||||
std::string home_path = std::string(home) + DIR_SEP;
|
||||
const char* config_home = getenv("XDG_CONFIG_HOME");
|
||||
sysDir = std::string(config_home && config_home[0] == '/'
|
||||
? config_home : (home_path + ".config"))
|
||||
+ DIR_SEP DOLPHIN_DATA_DIR DIR_SEP "Sys" DIR_SEP;
|
||||
#endif
|
||||
sysDir += DIR_SEP;
|
||||
|
||||
INFO_LOG(COMMON, "GetSysDirectory: Setting to %s:", sysDir.c_str());
|
||||
return sysDir;
|
||||
|
|
|
@ -163,6 +163,9 @@ bool DeleteDirRecursively(const std::string& directory);
|
|||
// Returns the current directory
|
||||
std::string GetCurrentDir();
|
||||
|
||||
// Gets the last modified time of a file
|
||||
u64 GetFileModTime(const std::string& path);
|
||||
|
||||
// Create directory and copy contents (optionally overwrites existing files)
|
||||
void CopyDir(const std::string& source_path, const std::string& dest_path,
|
||||
bool destructive = false);
|
||||
|
@ -200,6 +203,7 @@ std::string GetBundleDirectory();
|
|||
|
||||
std::string GetExePath();
|
||||
std::string GetExeDirectory();
|
||||
std::string GetHomeDirectory();
|
||||
|
||||
bool WriteStringToFile(const std::string& filename, std::string_view str);
|
||||
bool ReadFileToString(const std::string& filename, std::string& str);
|
||||
|
|
|
@ -15,4 +15,5 @@ extern const std::string scm_rev_str;
|
|||
extern const std::string scm_rev_git_str;
|
||||
extern const std::string scm_distributor_str;
|
||||
extern const std::string netplay_dolphin_ver;
|
||||
extern const std::string scm_slippi_semver_str;
|
||||
} // namespace Common
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue