From f661438c93806e42cfbbbd39d79c77924a4a5a16 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 15 Apr 2024 04:53:42 +0630 Subject: Moved read_file to a general base library --- asm/main.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'asm/main.cpp') diff --git a/asm/main.cpp b/asm/main.cpp index 51600cb..be26426 100644 --- a/asm/main.cpp +++ b/asm/main.cpp @@ -20,28 +20,11 @@ #include +#include "./base.hpp" #include "./lexer.hpp" using std::pair, std::string, std::string_view, std::vector; -std::optional read_file(const char *filename) -{ - FILE *fp = fopen(filename, "rb"); - if (fp) - { - string contents; - fseek(fp, 0, SEEK_END); - contents.resize(ftell(fp)); - rewind(fp); - fread(&contents[0], 1, contents.size(), fp); - fclose(fp); - - return contents; - } - else - return std::nullopt; -} - void usage(const char *program_name, FILE *fp) { fprintf(fp, -- cgit v1.2.3-13-gbd6f