mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-11 03:39:59 +00:00
750c0cab35
* remove fake match * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "3e9ed72e2" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "3e9ed72e2" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * new extraction script and a hack to make clear tag work * fix clear tag again * remove static from clear tag DLists * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "e7a8a48cf" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "e7a8a48cf" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "e243634e5" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "e243634e5" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "d0cd6b397" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "d0cd6b397" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Update ovl_En_Clear_Tag.xml
78 lines
2 KiB
C++
78 lines
2 KiB
C++
#pragma once
|
|
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <stdio.h>
|
|
#include <string>
|
|
#include <vector>
|
|
#include "Directory.h"
|
|
#include "Utils/StringHelper.h"
|
|
|
|
class File
|
|
{
|
|
public:
|
|
static bool Exists(const fs::path& filePath)
|
|
{
|
|
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
|
|
return file.good();
|
|
}
|
|
|
|
static std::vector<uint8_t> ReadAllBytes(const fs::path& filePath)
|
|
{
|
|
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
|
|
int32_t fileSize = (int32_t)file.tellg();
|
|
file.seekg(0);
|
|
char* data = new char[fileSize];
|
|
file.read(data, fileSize);
|
|
std::vector<uint8_t> result = std::vector<uint8_t>(data, data + fileSize);
|
|
delete[] data;
|
|
|
|
return result;
|
|
};
|
|
|
|
static std::string ReadAllText(const fs::path& filePath)
|
|
{
|
|
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
|
|
int32_t fileSize = (int32_t)file.tellg();
|
|
file.seekg(0);
|
|
char* data = new char[fileSize + 1];
|
|
memset(data, 0, fileSize + 1);
|
|
file.read(data, fileSize);
|
|
std::string str = std::string((const char*)data);
|
|
delete[] data;
|
|
|
|
return str;
|
|
};
|
|
|
|
static std::vector<std::string> ReadAllLines(const fs::path& filePath)
|
|
{
|
|
std::string text = ReadAllText(filePath);
|
|
std::vector<std::string> lines = StringHelper::Split(text, "\n");
|
|
|
|
return lines;
|
|
};
|
|
|
|
static void WriteAllBytes(const fs::path& filePath, const std::vector<uint8_t>& data)
|
|
{
|
|
std::ofstream file(filePath, std::ios::binary);
|
|
file.write((char*)data.data(), data.size());
|
|
};
|
|
|
|
static void WriteAllBytes(const std::string& filePath, const std::vector<char>& data)
|
|
{
|
|
std::ofstream file(filePath, std::ios::binary);
|
|
file.write((char*)data.data(), data.size());
|
|
};
|
|
|
|
static void WriteAllBytes(const std::string& filePath, const char* data, int dataSize)
|
|
{
|
|
std::ofstream file(filePath, std::ios::binary);
|
|
file.write((char*)data, dataSize);
|
|
};
|
|
|
|
static void WriteAllText(const fs::path& filePath, const std::string& text)
|
|
{
|
|
std::ofstream file(filePath, std::ios::out);
|
|
file.write(text.c_str(), text.size());
|
|
}
|
|
};
|