mirror of
https://github.com/libretro/devilutionX.git
synced 2026-11-10 17:20:56 -10:00
With this, we no longer require `std::filesystem` support to create the save file directory when it does not exist. Note that by default the save file directory exists because it is created by SDL, so this is mostly useful on platforms that override the save directory or use `UNPACKED_SAVES`.
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "utils/stdcompat/string_view.hpp"
|
|
|
|
namespace devilution {
|
|
|
|
#ifdef _WIN32
|
|
constexpr char DirectorySeparator = '\\';
|
|
#define DIRECTORY_SEPARATOR_STR "\\"
|
|
#else
|
|
constexpr char DirectorySeparator = '/';
|
|
#define DIRECTORY_SEPARATOR_STR "/"
|
|
#endif
|
|
|
|
bool FileExists(const char *path);
|
|
|
|
inline bool FileExists(const std::string &str)
|
|
{
|
|
return FileExists(str.c_str());
|
|
}
|
|
|
|
bool DirectoryExists(const char *path);
|
|
string_view Dirname(string_view path);
|
|
bool FileExistsAndIsWriteable(const char *path);
|
|
bool GetFileSize(const char *path, std::uintmax_t *size);
|
|
|
|
/**
|
|
* @brief Creates a single directory (non-recursively).
|
|
*
|
|
* @return True if the directory already existed or has been created sucessfully.
|
|
*/
|
|
bool CreateDir(const char *path);
|
|
|
|
void RecursivelyCreateDir(const char *path);
|
|
bool ResizeFile(const char *path, std::uintmax_t size);
|
|
void RenameFile(const char *from, const char *to);
|
|
void CopyFileOverwrite(const char *from, const char *to);
|
|
void RemoveFile(const char *path);
|
|
FILE *OpenFile(const char *path, const char *mode);
|
|
|
|
#if (defined(_WIN64) || defined(_WIN32)) && !defined(NXDK)
|
|
std::unique_ptr<wchar_t[]> ToWideChar(string_view path);
|
|
#endif
|
|
|
|
} // namespace devilution
|