Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace cleanup script and Win32-specific function with std::filesystem #3292

Merged
merged 8 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
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 ? std::string(tmp_dir) : "/tmp") /
("oc" + std::to_string(hoc_pid())) / ".hl";
JCGoran marked this conversation as resolved.
Show resolved Hide resolved
std::filesystem::remove(path);
alkino marked this conversation as resolved.
Show resolved Hide resolved
}

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
Loading