mirror of
https://github.com/Yet-Another-DreamTeam/quicknote.git
synced 2026-03-13 08:09:41 +00:00
add basic setup.h
This commit is contained in:
parent
d54ff2d7c4
commit
1ad84f1559
10
makefile
10
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
|
||||
$(CC) $(CFLAGS) -o ./bin/quicknote ./src/main.cpp
|
||||
|
||||
clean:
|
||||
rm -rf ./bin/quicknote
|
||||
|
||||
install:
|
||||
cp ./bin/quicknote /usr/local/bin/quicknote
|
||||
|
||||
@ -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
4
src/main.h
Normal file
@ -0,0 +1,4 @@
|
||||
#include <iostream>
|
||||
#include "./setup.h"
|
||||
|
||||
Setup setup;
|
||||
52
src/setup.h
Normal file
52
src/setup.h
Normal 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
|
||||
Loading…
x
Reference in New Issue
Block a user