Better handle file- or path-names with spaces

This commit is contained in:
Axel Kohlmeyer
2022-05-26 21:40:33 -04:00
parent 5f811f852f
commit e2dd08a93e
4 changed files with 7 additions and 5 deletions

View File

@ -31,5 +31,7 @@ set(temp "${temp}const char *LAMMPS_NS::LAMMPS::git_descriptor() { return \"${te
set(temp "${temp}#endif\n\n")
message(STATUS "Generating lmpgitversion.h...")
file(WRITE "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${temp}" )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h")
string(REPLACE "\\ " " " LAMMPS_GIT_HEADER "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h")
file(WRITE "${LAMMPS_GIT_HEADER}.tmp" "${temp}" )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_GIT_HEADER}.tmp" "${LAMMPS_GIT_HEADER}")

View File

@ -102,7 +102,7 @@ public:
BEGIN_HIDE_OUTPUT();
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
std::string cmdline =
fmt::format("{} -d -c {} > {}", COMPRESS_EXECUTABLE, compressed_file, converted_file);
fmt::format("\"{}\" -d -c {} > {}", COMPRESS_EXECUTABLE, compressed_file, converted_file);
system(cmdline.c_str());
END_HIDE_OUTPUT();
return converted_file;

View File

@ -100,7 +100,7 @@ public:
std::string convert_binary_to_text(std::string binary_file)
{
BEGIN_HIDE_OUTPUT();
std::string cmdline = fmt::format("{} {}", BINARY2TXT_EXECUTABLE, binary_file);
std::string cmdline = fmt::format("\"{}\" {}", BINARY2TXT_EXECUTABLE, binary_file);
system(cmdline.c_str());
END_HIDE_OUTPUT();
return fmt::format("{}.txt", binary_file);

View File

@ -100,7 +100,7 @@ public:
std::string convert_binary_to_text(std::string binary_file)
{
BEGIN_HIDE_OUTPUT();
std::string cmdline = fmt::format("{} {}", BINARY2TXT_EXECUTABLE, binary_file);
std::string cmdline = fmt::format("\"{}\" {}", BINARY2TXT_EXECUTABLE, binary_file);
system(cmdline.c_str());
END_HIDE_OUTPUT();
return fmt::format("{}.txt", binary_file);