Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
korayustundag authored Apr 9, 2023
1 parent e154a0f commit 01ea285
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ Build amd64:
```bash
make amd64
```

35 changes: 35 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
#include <string>
#include <cstdio>
#include <sys/stat.h>

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;
}
}
15 changes: 15 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 01ea285

Please sign in to comment.