diff options
| author | aspiring_aurelian <tom.wells46@protonmail.com> | 2023-12-09 09:08:14 -0600 |
|---|---|---|
| committer | aspiring_aurelian <tom.wells46@protonmail.com> | 2023-12-09 09:08:14 -0600 |
| commit | 6cdf2324d714b5f87dac893b453129f7b4bc0413 (patch) | |
| tree | 27db23a12282eb06f6cb0921365c3829af511476 /main.c | |
| parent | 52bf3decff476d5642535757fe23d3a67aa50ecd (diff) | |
No longer overwrite existing makefile
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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) { |