1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-17 20:42:23 +00:00

ZAPD update (#612)

* remove roompoly

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "fd4d53a26"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "fd4d53a26"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"
This commit is contained in:
fig02 2021-01-08 19:38:28 -05:00 committed by GitHub
parent 5c6335f9fb
commit 1ff2f0f849
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
171 changed files with 1567 additions and 826 deletions

View file

@ -11,23 +11,26 @@
class File
{
public:
static bool Exists(std::string filePath)
static bool Exists(const std::string& filePath)
{
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
return file.good();
}
static std::vector<uint8_t> ReadAllBytes(std::string filePath)
static std::vector<uint8_t> ReadAllBytes(const std::string& filePath)
{
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
int fileSize = (int)file.tellg();
file.seekg(0);
char* data = new char[fileSize];
file.read(data, fileSize);
return std::vector<uint8_t>(data, data + fileSize);
std::vector<uint8_t> result = std::vector<uint8_t>(data, data + fileSize);
delete data;
return result;
};
static std::string ReadAllText(std::string filePath)
static std::string ReadAllText(const std::string& filePath)
{
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
int fileSize = (int)file.tellg();
@ -35,10 +38,13 @@ public:
char* data = new char[fileSize+1];
memset(data, 0, fileSize + 1);
file.read(data, fileSize);
return std::string((const char*)data);
std::string str = std::string((const char*)data);
delete data;
return str;
};
static std::vector<std::string> ReadAllLines(std::string filePath)
static std::vector<std::string> ReadAllLines(const std::string& filePath)
{
std::string text = ReadAllText(filePath);
std::vector<std::string> lines = StringHelper::Split(text, "\n");
@ -46,15 +52,15 @@ public:
return lines;
};
static void WriteAllBytes(std::string filePath, std::vector<uint8_t> data)
static void WriteAllBytes(const std::string& filePath, const std::vector<uint8_t>& data)
{
std::ofstream file(filePath, std::ios::binary);
file.write((char*)data.data(), data.size());
};
static void WriteAllText(std::string filePath, std::string text)
static void WriteAllText(const std::string& filePath, const std::string& text)
{
std::ofstream file(filePath, std::ios::out);
file.write(text.c_str(), text.size());
}
};
};