add basic setup.h

This commit is contained in:
lucaspalomodevelop 2023-10-03 12:59:09 +02:00
parent d54ff2d7c4
commit 1ad84f1559
4 changed files with 67 additions and 3 deletions

View File

@ -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
$(CC) $(CFLAGS) -o ./bin/quicknote ./src/main.cpp
clean:
rm -rf ./bin/quicknote
install:
cp ./bin/quicknote /usr/local/bin/quicknote

View File

@ -1,7 +1,9 @@
#include <iostream>
#include "./main.h"
int main(int argc, char *argv[])
{
setup.runSetup();
std::cout << "quicknote!" << std::endl;
return 0;
}

4
src/main.h Normal file
View File

@ -0,0 +1,4 @@
#include <iostream>
#include "./setup.h"
Setup setup;

52
src/setup.h Normal file
View File

@ -0,0 +1,52 @@
#ifndef SETUP_H
#define SETUP_H
#include <iostream>
#include <string>
#include <sys/stat.h>
#include <filesystem>
#include <fstream>
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