From c996eb4b3ef9ba87dc34c8e212f4cae4e8ee7477 Mon Sep 17 00:00:00 2001
From: Maximilien Siavelis <m@siav.pw>
Date: 周日, 21 4月 2019 22:43:06 +0800
Subject: [PATCH] Merge pull request #19 from willamowius/master

---
 src/tools/bootstrap/bootstrap.cpp |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/tools/bootstrap/bootstrap.cpp b/src/tools/bootstrap/bootstrap.cpp
index 6b22d59..4af84e9 100644
--- a/src/tools/bootstrap/bootstrap.cpp
+++ b/src/tools/bootstrap/bootstrap.cpp
@@ -3,6 +3,7 @@
 #include <string>
 #include <stdlib.h>
 #include <iostream> 
+#include <sys/stat.h>
 
 using namespace std;
 namespace license {
@@ -73,6 +74,12 @@
 }
 }
 
+bool file_exists (const std::string & name)
+{
+  struct stat buffer;
+  return (stat (name.c_str(), &buffer) == 0);
+}
+
 int main(int argc, char** argv) {
 
 	if (argc != 3) {
@@ -87,6 +94,11 @@
 	string private_fname = string(argv[1]);
 	string public_fname(argv[2]);
 
+	if (file_exists(private_fname) || file_exists(public_fname)) {
+		printf("Key files exist, skipping key generation. Do 'make clean' to generate new keys.\n");
+		exit(0);
+	}
+
 	license::generatePk(private_fname, public_fname);
 	return 0;
 }

--
Gitblit v1.9.1