mirror of
https://github.com/open-goal/jak-project
synced 2026-06-26 02:24:34 -04:00
5d7aa7cea1
Rotates the log files with a timestamp instead of copying all files and incrementing an integer. Increases the amount of info you have when looking at user's log files (ie. when looking at all the files, the file creation dates are accurate).  Also simplifies the API for setting the log file, and `gk` logs are now game specific with `jak1` or `jak2`. Which should be useful going forward. Lastly, added a flag to all CLIs to disable ansi colors for people that want to do so. Though at the same time, there is finally a workaround in jenkins to fix ANSI colors in the truncated log view -- so I'm not sure why anyone would want to get rid of the color information. You can even setup text editors to display the color info making log parsing much easier. Fixes #1917 --------- Co-authored-by: ManDude <7569514+ManDude@users.noreply.github.com>
72 lines
3.0 KiB
C++
72 lines
3.0 KiB
C++
#pragma once
|
|
|
|
/*!
|
|
* @file FileUtil.h
|
|
* Utility functions for reading and writing files.
|
|
*/
|
|
|
|
#ifdef _WIN32
|
|
#define NOMINMAX
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#endif
|
|
|
|
#include "third-party/filesystem.hpp"
|
|
|
|
#ifdef _WIN32
|
|
#undef FALSE
|
|
#endif
|
|
|
|
#include <optional>
|
|
#include <regex>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "common/common_types.h"
|
|
#include "common/versions/versions.h"
|
|
|
|
namespace fs = ghc::filesystem;
|
|
|
|
namespace file_util {
|
|
fs::path get_user_home_dir();
|
|
fs::path get_user_config_dir();
|
|
fs::path get_user_settings_dir(GameVersion game_version);
|
|
fs::path get_user_memcard_dir(GameVersion game_version);
|
|
fs::path get_user_misc_dir(GameVersion game_version);
|
|
fs::path get_jak_project_dir();
|
|
|
|
bool create_dir_if_needed(const fs::path& path);
|
|
bool create_dir_if_needed_for_file(const std::string& path);
|
|
bool create_dir_if_needed_for_file(const fs::path& path);
|
|
std::optional<std::string> try_get_project_path_from_path(const std::string& path);
|
|
bool setup_project_path(std::optional<fs::path> project_path_override);
|
|
std::string get_file_path(const std::vector<std::string>& path);
|
|
void write_binary_file(const std::string& name, const void* data, size_t size);
|
|
void write_binary_file(const fs::path& name, const void* data, size_t size);
|
|
void write_rgba_png(const fs::path& name, void* data, int w, int h);
|
|
void write_text_file(const std::string& file_name, const std::string& text);
|
|
void write_text_file(const fs::path& file_name, const std::string& text);
|
|
std::vector<uint8_t> read_binary_file(const std::string& filename);
|
|
std::vector<uint8_t> read_binary_file(const fs::path& filename);
|
|
std::string read_text_file(const std::string& path);
|
|
std::string read_text_file(const fs::path& path);
|
|
bool is_printable_char(char c);
|
|
std::string combine_path(const std::string& parent, const std::string& child);
|
|
bool file_exists(const std::string& path);
|
|
std::string base_name(const std::string& filename);
|
|
std::string base_name_no_ext(const std::string& filename);
|
|
std::string split_path_at(const fs::path& path, const std::vector<std::string>& folders);
|
|
std::string convert_to_unix_path_separators(const std::string& path);
|
|
void MakeISOName(char* dst, const char* src);
|
|
void ISONameFromAnimationName(char* dst, const char* src);
|
|
void assert_file_exists(const char* path, const char* error_message);
|
|
bool dgo_header_is_compressed(const std::vector<u8>& data);
|
|
std::vector<u8> decompress_dgo(const std::vector<u8>& data_in);
|
|
FILE* open_file(const fs::path& path, const std::string& mode);
|
|
std::vector<fs::path> find_files_recursively(const fs::path& base_dir, const std::regex& pattern);
|
|
std::vector<fs::path> find_directories_in_dir(const fs::path& base_dir);
|
|
std::vector<fs::path> sort_filepaths(const std::vector<fs::path>& paths, const bool aescending);
|
|
/// Will overwrite the destination if it exists
|
|
void copy_file(const fs::path& src, const fs::path& dst);
|
|
std::string make_screenshot_filepath(const GameVersion game_version, const std::string& name = "");
|
|
} // namespace file_util
|