Skip to content

Incomplete Implementation for Windows OS in svzerodsolver.cpp: Reads input files but does not save path for output.csv #238

Description

@mmegally

Description

On Windows machines, the code for reading the input files works, but that path is not properly handled with the implementation of the if/else statements:

if (argc == 3) {
output_file_name = argv[2];

} else {
// If output file is not provided, default is <path to .json>+"output.csv"
std::size_t end_of_path = input_file_name.rfind("/");

if (end_of_path == std::string::npos) {
  end_of_path = input_file_name.rfind("\\");  // For Windows paths (?)  **<-- will find input file**

  // If <path to .json> is still not found, use current directory
  if (end_of_path == std::string::npos) {
    output_file_path = ".";
  }
} else {
  output_file_path = input_file_name.substr(0, end_of_path); **<-- skips because if {} was evaluated (missing path)**
}

output_file_name = output_file_path + "/output.csv";
std::cout << "[svzerodsolver] Output will be written to '"
          << output_file_name << "'." << std::endl;
;

}

Reproduction

Any code that relies on svzerodsolver.cpp implementation (originally found from 0d simulations in svVascularize gui).

OS: Windows 11

Expected behavior

Adding one short else statement fixed this issue, allowing the output file to save properly on my machine:

if (end_of_path == std::string::npos) {
  end_of_path = input_file_name.rfind("\\");  

  // If <path to .json> is still not found, use current directory
  if (end_of_path == std::string::npos) {
    output_file_path = ".";
  }
  **else {
    output_file_path = input_file_name.substr(0, end_of_path); <-- new code
  }** 
} 
else {
  output_file_path = input_file_name.substr(0, end_of_path);
}

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct and Contributing Guidelines

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions