Skip to content

Commit

Permalink
Fixed input and output filename options to allow spaces in filenames
Browse files Browse the repository at this point in the history
It seems that boost::program_options::value<boost::filesystem::path>
doesn't allow filenames containing spaces.

boostorg/program_options#69

See #195
  • Loading branch information
chrisn committed Jan 26, 2024
1 parent 9966b78 commit b391708
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ bool Options::parseCommandLine(int argc, const char* const* argv)
{
program_name_ = argv[0];

std::string input_filename;
std::string output_filename;

std::string input_format;
std::string output_format;

Expand All @@ -152,13 +155,13 @@ bool Options::parseCommandLine(int argc, const char* const* argv)
"disable progress and information messages"
)(
"input-filename,i",
po::value<boost::filesystem::path>(&input_filename_),
po::value<std::string>(&input_filename),
FileFormat::isSupported(FileFormat::Opus) ?
"input file name (.mp3, .wav, .flac, .ogg, .oga, .opus, .dat, .json)" :
"input file name (.mp3, .wav, .flac, .ogg, .oga, .dat, .json)"
)(
"output-filename,o",
po::value<boost::filesystem::path>(&output_filename_),
po::value<std::string>(&output_filename),
"output file name (.wav, .dat, .png, .json)"
)(
"split-channels",
Expand Down Expand Up @@ -308,6 +311,12 @@ bool Options::parseCommandLine(int argc, const char* const* argv)
}
}

// TODO: po::value<boost::filesystem::path> doesn't allow filenames
// containing spaces.
// See https://github.com/boostorg/program_options/issues/69
input_filename_ = input_filename;
output_filename_ = output_filename;

has_input_format_ = hasOptionValue(variables_map, "input-format");
has_output_format_ = hasOptionValue(variables_map, "output-format");

Expand Down

0 comments on commit b391708

Please sign in to comment.