diff --git a/README.md b/README.md index 8448888..95fb0de 100644 --- a/README.md +++ b/README.md @@ -74,3 +74,4 @@ Build amd64: ```bash make amd64 ``` + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..4a27e1e --- /dev/null +++ b/main.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +inline bool CheckFileExist(const std::string& name) { + struct stat buffer; + return (stat (name.c_str(), &buffer) == 0); +} + +int main(int argc, char** argv) +{ + std::string val = "./"; + for (int i = 1; i < argc; ++i) + { + std::string data = argv[i]; + val += data + " "; + } + if (val == "./") + { + std::cout << "Error: Please enter a app name! Like: run firefox" << std::endl; + return 1; + } + + if (CheckFileExist(argv[1])) + { + int ret = std::system(val.c_str()); + return 0; + } + else + { + std::cout << "Error: File not found! \nFile Name:" << argv[1] << std::endl; + return 1; + } +} diff --git a/makefile b/makefile new file mode 100644 index 0000000..6034ae7 --- /dev/null +++ b/makefile @@ -0,0 +1,15 @@ +CPP = g++ +CPPFLAGS = -O3 +build: + mkdir -p bin + $(CPP) $(CPPFLAGS) main.cpp -o bin/run +x86: + mkdir -p bin + mkdir -p bin/x86 + $(CPP) $(CPPFLAGS) -m32 main.cpp -o bin/x86/run +amd64: + mkdir -p bin + mkdir -p bin/amd64 + $(CPP) $(CPPFLAGS) -m64 main.cpp -o bin/amd64/run +clean: + if [ -d "bin" ]; then rm -Rf bin; fi