Skip to content

Commit cf719bd

Browse files
committed
Tune: Sketch cppexec main.
1 parent 074c46e commit cf719bd

1 file changed

Lines changed: 36 additions & 5 deletions

File tree

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
1-
#include "..\Project.h"
1+
#include "..\Project.h"
2+
#include <filesystem>
3+
using namespace std;
4+
using namespace filesystem;
25

3-
int wmain(int argc, wchar_t** argv)
4-
{
6+
int wmain(int argc, wchar_t** argv)
7+
{
8+
path exePath(argv[0]);
9+
auto dir = weakly_canonical(exePath).parent_path();
10+
path scriptToRun;
511

6-
return 0;
7-
}
12+
for (auto& pit : directory_iterator(dir))
13+
{
14+
auto& filePath = pit.path();
15+
auto ext = filePath.extension();
16+
17+
if( ext == ".cpp")
18+
{
19+
if(scriptToRun.empty())
20+
{
21+
scriptToRun = filePath;
22+
}
23+
else
24+
{
25+
scriptToRun.clear();
26+
break;
27+
}
28+
}
29+
} //for
30+
31+
if(scriptToRun.empty())
32+
{
33+
printf("Usage: %S <.cpp script to run>\r\n", exePath.stem().c_str());
34+
return -2;
35+
}
36+
37+
return 0;
38+
}
839

0 commit comments

Comments
 (0)