clang-format all the things

This commit is contained in:
Tyler Wilding
2020-08-26 01:21:33 -04:00
parent 50814f8529
commit 3c4fcbdd34
72 changed files with 772 additions and 795 deletions
+6 -6
View File
@@ -16,7 +16,8 @@ std::string combine_path(const std::string& parent, const std::string& child) {
std::vector<uint8_t> read_binary_file(const std::string& filename) {
auto fp = fopen(filename.c_str(), "rb");
if(!fp) throw std::runtime_error("File " + filename + " cannot be opened");
if (!fp)
throw std::runtime_error("File " + filename + " cannot be opened");
fseek(fp, 0, SEEK_END);
auto len = ftell(fp);
rewind(fp);
@@ -24,7 +25,7 @@ std::vector<uint8_t> read_binary_file(const std::string& filename) {
std::vector<uint8_t> data;
data.resize(len);
if(fread(data.data(), len, 1, fp) != 1) {
if (fread(data.data(), len, 1, fp) != 1) {
throw std::runtime_error("File " + filename + " cannot be read");
}
@@ -34,8 +35,8 @@ std::vector<uint8_t> read_binary_file(const std::string& filename) {
std::string base_name(const std::string& filename) {
size_t pos = 0;
assert(!filename.empty());
for(size_t i = filename.size() - 1; i-- > 0;) {
if(filename.at(i) == '/') {
for (size_t i = filename.size() - 1; i-- > 0;) {
if (filename.at(i) == '/') {
pos = (i + 1);
break;
}
@@ -66,14 +67,13 @@ uint32_t crc32(const uint8_t* data, size_t size) {
return ~crc;
}
uint32_t crc32(const std::vector<uint8_t>& data) {
return crc32(data.data(), data.size());
}
void write_text_file(const std::string& file_name, const std::string& text) {
FILE* fp = fopen(file_name.c_str(), "w");
if(!fp) {
if (!fp) {
printf("Failed to fopen %s\n", file_name.c_str());
throw std::runtime_error("Failed to open file");
}