From ef42fe57226a3b734769bf405bcd2200ec4c4216 Mon Sep 17 00:00:00 2001 From: Greg Wells Date: Sat, 17 May 2025 13:21:37 -0400 Subject: [PATCH] Get rid of Gryphn File API --- include/gryphn/gryphn_utils.h | 2 +- src/utils/files/gryphn_file.cpp | 51 --------------------------------- src/utils/files/gryphn_file.h | 44 ---------------------------- src/utils/gryphn_bool.h | 3 ++ 4 files changed, 4 insertions(+), 96 deletions(-) delete mode 100644 src/utils/files/gryphn_file.cpp delete mode 100644 src/utils/files/gryphn_file.h diff --git a/include/gryphn/gryphn_utils.h b/include/gryphn/gryphn_utils.h index ab08808..2e479ce 100644 --- a/include/gryphn/gryphn_utils.h +++ b/include/gryphn/gryphn_utils.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include typedef uint32_t gnUInt; diff --git a/src/utils/files/gryphn_file.cpp b/src/utils/files/gryphn_file.cpp deleted file mode 100644 index 74a388a..0000000 --- a/src/utils/files/gryphn_file.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#define GN_UTILS_CPP -#include "gryphn_file.h" -#include "fstream" -#include "iostream" - - -gnFile gnLoadFile(const gnString& path, gnFileType type) { - gnFile new_file = gnFile(); - - if (type == gnFileType::Text) { - std::ifstream file(gnToCString(path)); - if (!file.is_open()) throw std::runtime_error("failed to open text file!"); // thats right I wont use std::vector but il use std::runtime_error my priorities are straight - // not as straight as me around ethan mooney, il see myself out now. (PS i actually did go to bed these will stop now) - - std::string line; - while(std::getline(file, line)) { - gnListAdd(new_file.lines, gnCreateString(line.c_str())); - } - } else if (type == gnFileType::Binary) { - std::ifstream file(gnToCString(path), std::ios::ate | std::ios::binary); - - if (!file.is_open()) throw std::runtime_error("failed to open file!"); - - size_t file_size = (size_t)file.tellg(); - new_file.bytes = gnCreateList(file_size); - - file.seekg(0); - file.read(gnListData(new_file.bytes), file_size); - - file.close(); // straight from vulkan-tutorial.com, not as strai, imma stop myself now - } - new_file.path = path; - - return new_file; -} - -gnString gnGetFileData(const gnFile& file) { - gnString file_data; - for (int i = 0; i < gnListLength(file.lines); i++) { - file_data += gnListGet(file.lines, i) + '\n'; - } - return file_data; -} // why I dont just return the file as a list of lines, cuz thats the easy way this way revealed so many errors in my string class, - // dont you love it when you dont actually copy a string and then the data gets lost and you dont know why because your an idiot - // thats never happened to me...... yea so im an idiot shouve actually copied the bytes over not just haphazardly asigned them to a string. - -gnString gnGetFilePath(const gnFile& file) { - return file.path; -} - -gnList gnGetFileBytes(const gnFile& file) { return file.bytes; } diff --git a/src/utils/files/gryphn_file.h b/src/utils/files/gryphn_file.h deleted file mode 100644 index 0bf9c4f..0000000 --- a/src/utils/files/gryphn_file.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once -#include - -// TODO: this file API is shit -// have you ever wanted to write a file, well too bad cuz that shits a lot of work and im not doing allllll that -// also like im pretty sure something is fucked up in the reading of binary files, what, I dont know but something is -// other than that im pretty happy with it cuz like I still have zero fuckcking clue how it works -// the binary part that is - -#include "../strings/gryphn_string.h" -#include "../lists/gryphn_list.h" - -enum class gnFileType { - Text, Binary -}; - -struct gnFile { -ACCESS_LEVEL: - gnList lines = gnCreateList(); // if file type is string - gnList bytes = gnCreateList(); // if file type is binary - // ofc dumbass they should know what file type there loading - // wellllllll actually this is horrible cuz im storing the like 4 bytes it take for an empty list in every loaded file - // regardless of if there is actually any data in the list - // buttttt as code astetic once said "premature optimization is like totally the root of all evil bro *procedes to hit bong*" - // i think i remember that right, i need to fix this but templates are hard and im not - - gnString path = gnCreateEmptyString(); - gnFileType type = gnFileType::Text; // who loads binary files anyway *silence*, i do I guess thats why I wrote this -public: - gnFile() {} -}; - -gnFile gnLoadFile(const gnString& path, gnFileType type = gnFileType::Text); -// gnFile gnCreateFile(const gnString& path); -// gnFile gnCreateFile(); -// gnFile gnWriteFile(const gnFile& file); -// which fucking loser thought they were writing a file writing API -// ...... that was me, im lazy, its 10:30, 2.5 hours after I go to sleep, imma go to sleep. - -gnString gnGetFilePath(const gnFile& file); -gnString gnGetFileData(const gnFile& file); // i should rename this -gnList gnGetFileBytes(const gnFile& file); // fuck object oriented code - // and fuck error detection the user can get the bytes of a text file if they want to cuz its slow to do error checking, its also smart but im slow - // so me and this project are one in the same diff --git a/src/utils/gryphn_bool.h b/src/utils/gryphn_bool.h index 3199dbc..eab0a5e 100644 --- a/src/utils/gryphn_bool.h +++ b/src/utils/gryphn_bool.h @@ -1,5 +1,8 @@ #pragma once +#include "stdlib.h" typedef int gnBool; #define gnFalse 0; #define gnTrue 1; + +typedef size_t gnSize;