diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c80797..4d1076f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ set (PROGRAM_EXE ${CMAKE_PROJECT_NAME}) set (PROGRAM_SOURCE src/console.cpp + src/core/file.cpp src/core/dictionary.cpp src/string.cpp src/base58.cpp diff --git a/src/core/file.cpp b/src/core/file.cpp new file mode 100644 index 0000000..72c01b8 --- /dev/null +++ b/src/core/file.cpp @@ -0,0 +1,26 @@ + +#include +#include "file.h" + +namespace eoskeygen { + +bool readLines(const std::string& filename, strlist_t& lines) { + + FILE *fd; + char buf[1024]; + + fd = fopen(filename.c_str(), "r"); + if (!fd) { + return false; + } + + while(fgets(buf, sizeof(buf), fd) != NULL) { + std::string line(buf); + lines.push_back(trim(line)); + } + + fclose(fd); + return true; +} + +} // namespace eoskeygen diff --git a/src/core/file.h b/src/core/file.h new file mode 100644 index 0000000..19ce2ae --- /dev/null +++ b/src/core/file.h @@ -0,0 +1,36 @@ +/** + * MIT License + * + * Copyright (c) 2019-2020 EOS Sw/eden + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef EOSIOKEYGEN_CORE_FILE_H +#define EOSIOKEYGEN_CORE_FILE_H + +#include "../string.h" +#include + +namespace eoskeygen { + +bool readLines(const std::string& filename, strlist_t& lines); + +} // namespace + +#endif /* EOSIOKEYGEN_CORE_FILE_H */