replace linux file macros with std::filesystem usage
This commit is contained in:
@@ -389,11 +389,8 @@ absl::Status Controller::LoadFontFamilies() const {
|
|||||||
for (const auto &font_path : font_paths) {
|
for (const auto &font_path : font_paths) {
|
||||||
float font_size =
|
float font_size =
|
||||||
(font_path == DROID_SANS) ? FONT_SIZE_DROID_SANS : FONT_SIZE_DEFAULT;
|
(font_path == DROID_SANS) ? FONT_SIZE_DROID_SANS : FONT_SIZE_DEFAULT;
|
||||||
std::string actual_font_path = font_path;
|
std::string actual_font_path =
|
||||||
#ifdef __linux__
|
std::filesystem::absolute(font_path).string();
|
||||||
std::string const HOME = std::getenv("HOME") ? std::getenv("HOME") : ".";
|
|
||||||
actual_font_path = absl::StrCat(HOME, "/", font_path);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!io.Fonts->AddFontFromFileTTF(actual_font_path.data(), font_size)) {
|
if (!io.Fonts->AddFontFromFileTTF(actual_font_path.data(), font_size)) {
|
||||||
return absl::InternalError(
|
return absl::InternalError(
|
||||||
@@ -402,19 +399,15 @@ absl::Status Controller::LoadFontFamilies() const {
|
|||||||
|
|
||||||
// Merge icon set
|
// Merge icon set
|
||||||
const char *icon_font_path = FONT_ICON_FILE_NAME_MD;
|
const char *icon_font_path = FONT_ICON_FILE_NAME_MD;
|
||||||
std::string actual_icon_font_path = icon_font_path;
|
std::string actual_icon_font_path =
|
||||||
#ifdef __linux__
|
std::filesystem::absolute(icon_font_path).string();
|
||||||
actual_icon_font_path = absl::StrCat(HOME, "/", icon_font_path);
|
|
||||||
#endif
|
|
||||||
io.Fonts->AddFontFromFileTTF(actual_icon_font_path.data(), ICON_FONT_SIZE,
|
io.Fonts->AddFontFromFileTTF(actual_icon_font_path.data(), ICON_FONT_SIZE,
|
||||||
&icons_config, icons_ranges);
|
&icons_config, icons_ranges);
|
||||||
|
|
||||||
// Merge Japanese font
|
// Merge Japanese font
|
||||||
const char *japanese_font_path = NOTO_SANS_JP;
|
const char *japanese_font_path = NOTO_SANS_JP;
|
||||||
std::string actual_japanese_font_path = japanese_font_path;
|
std::string actual_japanese_font_path =
|
||||||
#ifdef __linux__
|
std::filesystem::absolute(japanese_font_path).string();
|
||||||
actual_japanese_font_path = absl::StrCat(HOME, "/", japanese_font_path);
|
|
||||||
#endif
|
|
||||||
io.Fonts->AddFontFromFileTTF(actual_japanese_font_path.data(), 18.0f,
|
io.Fonts->AddFontFromFileTTF(actual_japanese_font_path.data(), 18.0f,
|
||||||
&japanese_font_config,
|
&japanese_font_config,
|
||||||
io.Fonts->GetGlyphRangesJapanese());
|
io.Fonts->GetGlyphRangesJapanese());
|
||||||
|
|||||||
@@ -127,12 +127,7 @@ absl::Status Rom::LoadAllGraphicsData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
absl::Status Rom::LoadFromFile(const std::string& filename, bool z3_load) {
|
absl::Status Rom::LoadFromFile(const std::string& filename, bool z3_load) {
|
||||||
std::string full_filename = filename;
|
std::string full_filename = std::filesystem::absolute(filename).string();
|
||||||
#ifdef __linux__
|
|
||||||
std::string const HOME = std::getenv("HOME") ? std::getenv("HOME") : ".";
|
|
||||||
std::cout << "Home directory: " << HOME << std::endl;
|
|
||||||
full_filename = absl::StrCat(HOME, "/", filename);
|
|
||||||
#endif
|
|
||||||
if (full_filename.empty()) {
|
if (full_filename.empty()) {
|
||||||
return absl::InvalidArgumentError(
|
return absl::InvalidArgumentError(
|
||||||
"Could not load ROM: parameter `filename` is empty.");
|
"Could not load ROM: parameter `filename` is empty.");
|
||||||
@@ -144,7 +139,7 @@ absl::Status Rom::LoadFromFile(const std::string& filename, bool z3_load) {
|
|||||||
std::ifstream file(filename_, std::ios::binary);
|
std::ifstream file(filename_, std::ios::binary);
|
||||||
if (!file.is_open()) {
|
if (!file.is_open()) {
|
||||||
return absl::InternalError(
|
return absl::InternalError(
|
||||||
absl::StrCat("Could not open ROM file: ", filename));
|
absl::StrCat("Could not open ROM file: ", filename_));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get file size and resize rom_data_
|
// Get file size and resize rom_data_
|
||||||
@@ -152,7 +147,7 @@ absl::Status Rom::LoadFromFile(const std::string& filename, bool z3_load) {
|
|||||||
size_ = std::filesystem::file_size(filename_);
|
size_ = std::filesystem::file_size(filename_);
|
||||||
} catch (const std::filesystem::filesystem_error& e) {
|
} catch (const std::filesystem::filesystem_error& e) {
|
||||||
return absl::InternalError(
|
return absl::InternalError(
|
||||||
absl::StrCat("Could not get file size: ", filename, " - ", e.what()));
|
absl::StrCat("Could not get file size: ", filename_, " - ", e.what()));
|
||||||
}
|
}
|
||||||
rom_data_.resize(size_);
|
rom_data_.resize(size_);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user