idk
This commit is contained in:
parent
f5b3f3c33f
commit
a7a447552e
@ -12,6 +12,7 @@
|
|||||||
#include "../physics/Hitbox.h"
|
#include "../physics/Hitbox.h"
|
||||||
#include "../util/stringutil.h"
|
#include "../util/stringutil.h"
|
||||||
#include "../voxels/Block.h"
|
#include "../voxels/Block.h"
|
||||||
|
#include "../voxels/Chunk.h"
|
||||||
#include "../voxels/Chunks.h"
|
#include "../voxels/Chunks.h"
|
||||||
#include "../world/Level.h"
|
#include "../world/Level.h"
|
||||||
#include "../world/World.h"
|
#include "../world/World.h"
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "stringutil.h"
|
#include "stringutil.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@ -424,3 +425,22 @@ std::vector<std::wstring> util::split(const std::wstring& str, char delimiter) {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string util::format_data_size(size_t size) {
|
||||||
|
if (size < 1024) {
|
||||||
|
return std::to_string(size)+" B";
|
||||||
|
}
|
||||||
|
const std::string postfixes[] {
|
||||||
|
" B", " KiB", " MiB", " GiB", " TiB", " EiB", " PiB"
|
||||||
|
};
|
||||||
|
int group = 0;
|
||||||
|
size_t remainder;
|
||||||
|
while (size >= 1024) {
|
||||||
|
group++;
|
||||||
|
remainder = size % 1024;
|
||||||
|
size /= 1024;
|
||||||
|
}
|
||||||
|
return std::to_string(size)+"."+
|
||||||
|
std::to_string(static_cast<int>(round(remainder/1024.0f)))+
|
||||||
|
postfixes[group];
|
||||||
|
}
|
||||||
|
|||||||
@ -54,6 +54,8 @@ namespace util {
|
|||||||
|
|
||||||
extern std::vector<std::string> split(const std::string& str, char delimiter);
|
extern std::vector<std::string> split(const std::string& str, char delimiter);
|
||||||
extern std::vector<std::wstring> split(const std::wstring& str, char delimiter);
|
extern std::vector<std::wstring> split(const std::wstring& str, char delimiter);
|
||||||
|
|
||||||
|
extern std::string format_data_size(size_t size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // UTIL_STRINGUTIL_H_
|
#endif // UTIL_STRINGUTIL_H_
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user