aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/main.c b/main.c
index d25e435..b688864 100644
--- a/main.c
+++ b/main.c
@@ -31,8 +31,12 @@ void *f1_newer(void *arg) {
}
void *create_template(void *arg) {
- /* Create simple main.c and makefile boilerplate */
+ /* Create simple main.c or makefile boilerplate */
char *path = (char *) arg;
+ struct stat attr;
+ if (stat(path, &attr) == 0) {
+ return NULL;
+ }
int fd = creat(path, 00644);
FILE *file = fdopen(fd, "w");
switch(path[2]) {
@@ -54,12 +58,13 @@ void new(char *argv[]) {
char *name = argv[2];
mkdir(name, 0777);
chdir(name);
+
pthread_t s_thread, m_thread;
pthread_create(&s_thread, NULL, create_template, (void *) "main.c");
pthread_create(&m_thread, NULL, create_template, (void *) "makefile");
-
pthread_join(s_thread, NULL);
pthread_join(m_thread, NULL);
+
printf("Created project: %s\n", name);
exit(0);
}
@@ -123,9 +128,9 @@ int main(int argc, char *argv[]) {
break;
default:
execl("/usr/bin/make", "make", "debug", NULL);
- printf("\n");
}
}
+ if (mode == RUN) printf("\n");
waitpid(make_pid, NULL, 0);
}
else if (mode == BUILD || mode == BUILD_RELEASE) {