main
anulax1225 ago%!(EXTRA string=7 months)
parent 74846d6deb
commit 603f89baa6
  1. 3
      src/bakatools/container/data_stream.h
  2. 2
      src/bakatools/file_system/dir_entry.cpp
  3. 3
      src/bakatools/file_system/dir_entry.h
  4. 3
      src/bakatools/file_system/file.cpp
  5. 2
      src/bakatools/file_system/file.h
  6. 10
      src/bakatools/logging/assert.h

@ -2,6 +2,7 @@
#include <bakatoolspch.h> #include <bakatoolspch.h>
#include <initializer_list> #include <initializer_list>
#include <string>
namespace Bk::Type { namespace Bk::Type {
class DataStream class DataStream
@ -13,6 +14,8 @@ namespace Bk::Type {
DataStream(std::vector<char> data) DataStream(std::vector<char> data)
: payload(data) {} : payload(data) {}
operator std::string() { return std::string(payload.data(), payload.size()); }
int size() { return payload.size(); } int size() { return payload.size(); }
void reverse() { std::reverse(payload.begin(), payload.end()); } void reverse() { std::reverse(payload.begin(), payload.end()); }

@ -24,7 +24,7 @@ namespace Bk
return ent.path().filename().string(); return ent.path().filename().string();
} }
uintmax_t DirEntry::size() u64 DirEntry::size()
{ {
return ent.file_size(); return ent.file_size();
} }

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <bakatoolspch.h> #include <bakatoolspch.h>
#include "bakatools/container/types.h"
#include <bits/chrono.h> #include <bits/chrono.h>
#include <chrono> #include <chrono>
@ -33,7 +34,7 @@ namespace Bk
std::string relative_path(); std::string relative_path();
std::string name(); std::string name();
uintmax_t size(); u64 size();
std::chrono::time_point<std::filesystem::__file_clock> last_write(); std::chrono::time_point<std::filesystem::__file_clock> last_write();
bool exists(); bool exists();
FilePerms perms(); FilePerms perms();

@ -11,8 +11,9 @@ namespace Bk {
if (exists()) std::filesystem::copy_file(ent.path(), path, opt); if (exists()) std::filesystem::copy_file(ent.path(), path, opt);
} }
Type::DataStream File::read(int size) Type::DataStream File::read(u64 size)
{ {
size = size ? size : this->size();
std::vector<char> data; std::vector<char> data;
if(exists()) if(exists())
{ {

@ -20,7 +20,7 @@ namespace Bk {
int remove(); int remove();
void copy(std::string path, CopyOption opt = CopyOption::overwrite_existing) override; void copy(std::string path, CopyOption opt = CopyOption::overwrite_existing) override;
Type::DataStream read(int size); Type::DataStream read(u64 size = 0);
bool write(Type::DataStream stream); bool write(Type::DataStream stream);
BK_DIR_ENTRY_TYPE(regular) BK_DIR_ENTRY_TYPE(regular)

@ -5,16 +5,16 @@ This file contains the assert macros. CORE macros musn't be used by the applicat
*/ */
#include "log.h" #include "log.h"
#include <bakatools/string/format.h> #include "bakatools/string/format.h"
#define BK_STATIC_DEBUGBREAK() exit(1) #define BK_STATIC_DEBUGBREAK() exit(1)
#define BK_STATIC_CORE_VAMSG_ASSERT(check, msg, ...) if(!(check)) { BK_STATIC_CORE_ERROR(Tools::format("Assertion [%s] failed at %s:%d\n\tError : %s", BK_STRINGIFY(check), __FILE__, __LINE__, msg), __VA_ARGS__); BK_STATIC_DEBUGBREAK(); } #define BK_STATIC_CORE_VAMSG_ASSERT(check, msg, ...) if(!(check)) { BK_STATIC_CORE_ERROR(Tools::string_format("Assertion [%s] failed at %s:%d\n\tError : %s", BK_STRINGIFY(check), __FILE__, __LINE__, msg), __VA_ARGS__); BK_STATIC_DEBUGBREAK(); }
#define BK_STATIC_CORE_MSG_ASSERT(check, msg) if(!(check)) { BK_STATIC_CORE_ERROR("Assertion [{0}] failed at {1}:{2}\n\tError : {3}", BK_STRINGIFY(check), __FILE__, __LINE__, msg); BK_STATIC_DEBUGBREAK(); } #define BK_STATIC_CORE_MSG_ASSERT(check, msg) if(!(check)) { BK_STATIC_CORE_ERROR("Assertion [{0}] failed at {1}:{2}\n\tError : {3}", BK_STRINGIFY(check), __FILE__, __LINE__, msg); BK_STATIC_DEBUGBREAK(); }
#define BK_STATIC_CORE_ASSERT(check) if(!(check)) { BK_STATIC_CORE_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_STATIC_DEBUGBREAK(); } #define BK_STATIC_CORE_ASSERT(check) if(!(check)) { BK_STATIC_CORE_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_STATIC_DEBUGBREAK(); }
#define BK_STATIC_VAMSG_ASSERT(check, msg, ...) if(!(check)) { BK_STATIC_ERROR(Bk::Tools::format("Assertion [%s] failed at %s:%d\n\tError : %s", BK_STRINGIFY(check), __FILE__, __LINE__, msg), __VA_ARGS__); BK_STATIC_DEBUGBREAK(); } #define BK_STATIC_VAMSG_ASSERT(check, msg, ...) if(!(check)) { BK_STATIC_ERROR(Bk::Tools::string_format("Assertion [%s] failed at %s:%d\n\tError : %s", BK_STRINGIFY(check), __FILE__, __LINE__, msg), __VA_ARGS__); BK_STATIC_DEBUGBREAK(); }
#define BK_STATIC_MSG_ASSERT(check, msg) if(!(check)) { BK_STATIC_ERROR("Assertion [{0}] failed at {1}:{2}\n\tError : {3}", BK_STRINGIFY(check), __FILE__, __LINE__, msg); BK_STATIC_DEBUGBREAK(); } #define BK_STATIC_MSG_ASSERT(check, msg) if(!(check)) { BK_STATIC_ERROR("Assertion [{0}] failed at {1}:{2}\n\tError : {3}", BK_STRINGIFY(check), __FILE__, __LINE__, msg); BK_STATIC_DEBUGBREAK(); }
#define BK_STATIC_ASSERT(check) if(!(check)) { BK_STATIC_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_STATIC_DEBUGBREAK(); } #define BK_STATIC_ASSERT(check) if(!(check)) { BK_STATIC_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_STATIC_DEBUGBREAK(); }
@ -33,11 +33,11 @@ This file contains the assert macros. CORE macros musn't be used by the applicat
@param msg : format string error message @param msg : format string error message
@param ... : variable arguments to put in the string @param ... : variable arguments to put in the string
*/ */
#define BK_CORE_VAMSG_ASSERT(check, msg, ...) if(!(check)) { BK_CORE_ERROR(Tools::format("Assertion [%s] failed at %s:%d\n\tError : %s", BK_STRINGIFY(check), __FILE__, __LINE__, msg), __VA_ARGS__); BK_DEBUGBREAK(); } #define BK_CORE_VAMSG_ASSERT(check, msg, ...) if(!(check)) { BK_CORE_ERROR(Tools::string_format("Assertion [%s] failed at %s:%d\n\tError : %s", BK_STRINGIFY(check), __FILE__, __LINE__, msg), __VA_ARGS__); BK_DEBUGBREAK(); }
#define BK_CORE_MSG_ASSERT(check, msg) if(!(check)) { BK_CORE_ERROR("Assertion [{0}] failed at {1}:{2}\n\tError : {3}", BK_STRINGIFY(check), __FILE__, __LINE__, msg); BK_DEBUGBREAK(); } #define BK_CORE_MSG_ASSERT(check, msg) if(!(check)) { BK_CORE_ERROR("Assertion [{0}] failed at {1}:{2}\n\tError : {3}", BK_STRINGIFY(check), __FILE__, __LINE__, msg); BK_DEBUGBREAK(); }
#define BK_CORE_ASSERT(check) if(!(check)) { BK_CORE_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_DEBUGBREAK(); } #define BK_CORE_ASSERT(check) if(!(check)) { BK_CORE_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_DEBUGBREAK(); }
#define BK_VAMSG_ASSERT(check, msg, ...) if(!(check)) { BK_ERROR(Bk::Tools::format("Assertion [%s] failed at %s:%d\n\tError : %s", BK_STRINGIFY(check), __FILE__, __LINE__, msg), __VA_ARGS__); BK_DEBUGBREAK(); } #define BK_VAMSG_ASSERT(check, msg, ...) if(!(check)) { BK_ERROR(Bk::Tools::string_format("Assertion [%s] failed at %s:%d\n\tError : %s", BK_STRINGIFY(check), __FILE__, __LINE__, msg), __VA_ARGS__); BK_DEBUGBREAK(); }
#define BK_MSG_ASSERT(check, msg) if(!(check)) { BK_ERROR("Assertion [{0}] failed at {1}:{2}\n\tError : {3}", BK_STRINGIFY(check), __FILE__, __LINE__, msg); BK_DEBUGBREAK(); } #define BK_MSG_ASSERT(check, msg) if(!(check)) { BK_ERROR("Assertion [{0}] failed at {1}:{2}\n\tError : {3}", BK_STRINGIFY(check), __FILE__, __LINE__, msg); BK_DEBUGBREAK(); }
#define BK_ASSERT(check) if(!(check)) { BK_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_DEBUGBREAK(); } #define BK_ASSERT(check) if(!(check)) { BK_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_DEBUGBREAK(); }
#else #else

Loading…
Cancel
Save