diff --git a/CMakeLists.txt b/CMakeLists.txt index 90df4b3935..48095702a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -916,8 +916,6 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/share/demo DESTINATION ${NRN_INSTA install(FILES ${PROJECT_BINARY_DIR}/share/nrn/lib/nrnunits.lib ${PROJECT_BINARY_DIR}/share/nrn/lib/nrn.defaults DESTINATION ${NRN_INSTALL_SHARE_DIR}/lib) -install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/share/lib/cleanup - DESTINATION ${NRN_INSTALL_SHARE_DIR}/lib) # Copy NEURON headers that will be included in the installation into the build directory. set(headers_in_build_dir) diff --git a/share/lib/cleanup b/share/lib/cleanup deleted file mode 100755 index 5ac223906d..0000000000 --- a/share/lib/cleanup +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -if [ $TEMP ] ; then - tmpdir=$TEMP -else - tmpdir="/tmp" -fi -rm -f $tmpdir/oc"$1".hl diff --git a/src/oc/hoc.cpp b/src/oc/hoc.cpp index 7d0c16932f..c1c8f34f9f 100644 --- a/src/oc/hoc.cpp +++ b/src/oc/hoc.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -168,9 +169,7 @@ static int c = '\n'; /* global for use by warning() */ void set_intset() { hoc_intset++; } -#endif -#ifdef WIN32 -extern void hoc_win32_cleanup(); +extern void ivoc_win32_cleanup(); #endif static int follow(int expect, int ifyes, int ifno); /* look ahead for >=, etc. */ @@ -960,16 +959,14 @@ 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; - } +#if defined(WIN32) && HAVE_IV + ivoc_win32_cleanup(); #endif + auto tmp_dir = std::getenv("TEMP"); + auto path = std::filesystem::path(tmp_dir ? std::string(tmp_dir) : "/tmp") / + fmt::format("oc{}.hl", hoc_pid()); + std::error_code ec; + std::filesystem::remove(path, ec); } void hoc_quit(void) { diff --git a/src/oc/mswinprt.cpp b/src/oc/mswinprt.cpp index 3dfa805a3c..29ae6ec491 100644 --- a/src/oc/mswinprt.cpp +++ b/src/oc/mswinprt.cpp @@ -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;