Skip to content

Commit

Permalink
Replace cleanup and Win32 script with std::filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
JCGoran committed Dec 14, 2024
1 parent bf6a457 commit 161f3ef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 34 deletions.
8 changes: 0 additions & 8 deletions share/lib/cleanup

This file was deleted.

18 changes: 5 additions & 13 deletions src/oc/hoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <cfenv>
#include <condition_variable>
#include <filesystem>
#include <iostream>
#include <mutex>
#include <thread>
Expand Down Expand Up @@ -169,9 +170,6 @@ void set_intset() {
hoc_intset++;
}
#endif
#ifdef WIN32
extern void hoc_win32_cleanup();
#endif

static int follow(int expect, int ifyes, int ifno); /* look ahead for >=, etc. */
static int Getc(NrnFILEWrap* fp);
Expand Down Expand Up @@ -960,16 +958,10 @@ void hoc_final_exit(void) {
rl_deprep_terminal();
#endif
ivoc_cleanup();
#ifdef WIN32
hoc_win32_cleanup();
#else
std::string cmd{neuron_home};
cmd += "/lib/cleanup ";
cmd += std::to_string(hoc_pid());
if (system(cmd.c_str())) { // fix warning: ignoring return value
return;
}
#endif
auto tmp_dir = std::getenv("TEMP");
auto path = std::filesystem::path(tmp_dir ? tmp_dir : "/tmp") / "oc" /
std::to_string(hoc_pid()) / ".hl";
std::filesystem::remove(path);
}

void hoc_quit(void) {
Expand Down
13 changes: 0 additions & 13 deletions src/oc/mswinprt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,6 @@ char* hoc_back2forward(char* s) {
void ivoc_win32_cleanup();
#endif

void hoc_win32_cleanup() {
char buf[256];
char* path;
#if HAVE_IV
ivoc_win32_cleanup();
#endif
path = getenv("TEMP");
if (path) {
Sprintf(buf, "%s/oc%d.hl", path, getpid());
unlink(buf);
// DebugMessage("unlinked %s\n", buf);
}
}

void hoc_win_exec(void) {
int i;
Expand Down

0 comments on commit 161f3ef

Please sign in to comment.