From 0f111cf51b00c4e884b7e53b4fd7ff6e38d8af5e Mon Sep 17 00:00:00 2001 From: untodesu Date: Fri, 26 Dec 2025 23:17:56 +0500 Subject: Add include guards and header comments to sources --- src/core/io/physfs.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/core/io/physfs.cc') diff --git a/src/core/io/physfs.cc b/src/core/io/physfs.cc index b9fe91e..04aaf64 100644 --- a/src/core/io/physfs.cc +++ b/src/core/io/physfs.cc @@ -1,13 +1,18 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: physfs.cc +// Description: PhysFS utilities + #include "core/pch.hh" #include "core/io/physfs.hh" -bool read_file(std::string_view path, std::vector& buffer) +bool physfs::read_file(std::string_view path, std::vector& buffer) { auto file = PHYSFS_openRead(std::string(path).c_str()); if(file == nullptr) { - spdlog::error("physfs: {}: {}", path, physfs_error()); + spdlog::error("physfs: {}: {}", path, physfs::last_error()); return false; } @@ -20,12 +25,12 @@ bool read_file(std::string_view path, std::vector& buffer) return true; } -bool read_file(std::string_view path, std::string& buffer) +bool physfs::read_file(std::string_view path, std::string& buffer) { auto file = PHYSFS_openRead(std::string(path).c_str()); if(file == nullptr) { - spdlog::error("physfs: {}: {}", path, physfs_error()); + spdlog::error("physfs: {}: {}", path, physfs::last_error()); return false; } @@ -38,12 +43,12 @@ bool read_file(std::string_view path, std::string& buffer) return true; } -bool write_file(std::string_view path, const std::vector& buffer) +bool physfs::write_file(std::string_view path, const std::vector& buffer) { auto file = PHYSFS_openWrite(std::string(path).c_str()); if(file == nullptr) { - spdlog::error("physfs: {}: {}", path, physfs_error()); + spdlog::error("physfs: {}: {}", path, physfs::last_error()); return false; } @@ -53,12 +58,12 @@ bool write_file(std::string_view path, const std::vector& buffer) return true; } -bool write_file(std::string_view path, const std::string& buffer) +bool physfs::write_file(std::string_view path, const std::string& buffer) { auto file = PHYSFS_openWrite(std::string(path).c_str()); if(file == nullptr) { - spdlog::error("physfs: {}: {}", path, physfs_error()); + spdlog::error("physfs: {}: {}", path, physfs::last_error()); return false; } @@ -68,7 +73,7 @@ bool write_file(std::string_view path, const std::string& buffer) return true; } -std::string_view physfs_error(void) +std::string_view physfs::last_error(void) { auto error_code = PHYSFS_getLastErrorCode(); auto error_string = PHYSFS_getErrorByCode(error_code); -- cgit