From 1ad84f155986a53c479480faa6833e3de2f0bcb9 Mon Sep 17 00:00:00 2001 From: lucaspalomodevelop Date: Tue, 3 Oct 2023 12:59:09 +0200 Subject: [PATCH] add basic setup.h --- makefile | 10 ++++++++-- src/main.cpp | 4 +++- src/main.h | 4 ++++ src/setup.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 src/main.h create mode 100644 src/setup.h diff --git a/makefile b/makefile index ff1618c..7f73578 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,11 @@ CC = g++ -CFLAGS = -Wall -O2 +CFLAGS = -std=c++17 -Wall -O2 -static -static-libgcc -static-libstdc++ all: - $(CC) $(CFLAGS) -o ./bin/quicknote ./src/main.cpp \ No newline at end of file + $(CC) $(CFLAGS) -o ./bin/quicknote ./src/main.cpp + +clean: + rm -rf ./bin/quicknote + +install: + cp ./bin/quicknote /usr/local/bin/quicknote diff --git a/src/main.cpp b/src/main.cpp index 3d4f688..00ef488 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,9 @@ -#include +#include "./main.h" int main(int argc, char *argv[]) { + + setup.runSetup(); std::cout << "quicknote!" << std::endl; return 0; } \ No newline at end of file diff --git a/src/main.h b/src/main.h new file mode 100644 index 0000000..9da570c --- /dev/null +++ b/src/main.h @@ -0,0 +1,4 @@ +#include +#include "./setup.h" + +Setup setup; \ No newline at end of file diff --git a/src/setup.h b/src/setup.h new file mode 100644 index 0000000..1f97bcc --- /dev/null +++ b/src/setup.h @@ -0,0 +1,52 @@ + + +#ifndef SETUP_H +#define SETUP_H + +#include +#include +#include +#include +#include + +class Setup +{ +private: +public: +#ifdef _WIN32 + + std::string home = getenv("USERPROFILE"); + std::string editor = "notepad.exe"; +#else + std::string home = getenv("HOME"); + std::string editor = "vim"; +#endif + Setup(/* args */) + { + home = home + "/.quicknote"; + + runSetup(); + } + + ~Setup() + { + } + + void createFolder() + { +#ifdef _WIN32 + mkdir((home).c_str()); +#else + mkdir((home).c_str(), 0777); +#endif + } + + void runSetup() + { + + if (!std::filesystem::exists(home)) + createFolder(); + } +}; + +#endif // SETUP_H \ No newline at end of file