You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.5 KiB

#pragma once
#include <cstdint>
#include <cstdio>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
namespace devilution {
dos: Clean up paths for better logging 1. Prevents warnings in `--verbose` mode from unimplemented `SDL_GetBase/PrefPath`. These were the first 4 "This operation is not supported" messages that were logged previously. 2. Removes Linux directories from MPQ search paths on DOS. 3. Uses backslash directory separator on DOS. DJGPP libc supports both but this is DOS, we should use backslash. Now the `--verbose` SDL_LOG.txt looks much cleaner: ``` VERBOSE: Paths: base: pref: config: assets: assets\ VERBOSE: MPQ search paths: 1. '' VERBOSE: Found: devx in VERBOSE: Missing: fonts DEBUG: DOS: Keyboard ISR code size is 48 bytes DEBUG: Unknown pixel format DEBUG: SVGA: Ignoring mode 0x102: Bad attributes DEBUG: SVGA: Ignoring mode 0x104: Bad attributes DEBUG: SVGA: Ignoring mode 0x106: Bad attributes DEBUG: SVGA: Ignoring mode 0x107: No double-buffering DEBUG: SVGA: Ignoring mode 0x112: No double-buffering DEBUG: SVGA: Ignoring mode 0x115: No double-buffering DEBUG: SVGA: Ignoring mode 0x116: No double-buffering DEBUG: SVGA: Ignoring mode 0x117: No double-buffering DEBUG: SVGA: Ignoring mode 0x209: No double-buffering DEBUG: SVGA: Ignoring mode 0x20A: No double-buffering DEBUG: SVGA: Ignoring mode 0x225: No double-buffering DEBUG: SVGA: VBE lists 42 modes VERBOSE: Removed file: Diablo1ReadOnlyTest.foo VERBOSE: Paths: base: pref: config: assets: assets\ VERBOSE: MPQ search paths: 1. '' VERBOSE: Paths: base: pref: config: assets: assets\ VERBOSE: MPQ search paths: 1. '' VERBOSE: Found: DIABDAT in VERBOSE: Missing: hfbard VERBOSE: Missing: hfbarb DEBUG: That operation is not supported VERBOSE: Control: device None -> KeyboardAndMouse, mode None -> KeyboardAndMouse ```
7 months ago
#if defined(_WIN32) || defined(__DJGPP__)
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);
std::string_view Dirname(std::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 successfully.
*/
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(_WIN32) && !defined(DEVILUTIONX_WINDOWS_NO_WCHAR)
std::unique_ptr<wchar_t[]> ToWideChar(std::string_view path);
#endif
std::vector<std::string> ListDirectories(const char *path);
std::vector<std::string> ListFiles(const char *path);
} // namespace devilution