Skip to content

Commit

Permalink
fix: remove temp dir in windows systems
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino committed Oct 7, 2024
1 parent a02e3db commit 90e713f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,11 @@ int main(int argc, char **argv) {
free(code);
tcc_delete(TCC);
if(tmpdir) {
#ifndef LIBC_MINGW32
rm_recursive(tmpdir);
#else
win32_rmdtemp(tmpdir);
#endif
}
_err("---\nExecution completed");
exit(res);
Expand Down
28 changes: 28 additions & 0 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,32 @@ char *win32_mkdtemp() {
}
return(tempDir);
}
void win32_rmdtemp(const char *path) {
static char sysTempDir[MAX_PATH];
static char secTempDir[MAX_PATH];
static char winTempDir[MAX_PATH];
PathCombine(sysTempDir, tempDir, "sys");
rm_recursive(sysTempDir);
if (RemoveDirectory(sysTempDir) == 0) {
_err("Failed to remove sys dir in temporary dir: %s",path);
return;
}
PathCombine(secTempDir, tempDir, "sec_api");
rm_recursive(secTempDir);
if (RemoveDirectory(secTempDir) == 0) {
_err("Failed to remove sec_api dir in temporary dir: %s",path);
return;
}
PathCombine(winTempDir, tempDir, "winapi");
rm_recursive(winTempDir);
if (RemoveDirectory(winTempDir) == 0) {
_err("Failed to remove winapi dir in temporary dir: %s",path);
return;
}
rm_recursive(path);
if (RemoveDirectory(path) == 0) {
_err("Failed to remove temporary dir: %s",path);
return;
}
}
#endif

0 comments on commit 90e713f

Please sign in to comment.