Skip to content

Commit

Permalink
Custom Mode: Immediately fail if any file does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
complexlogic committed Feb 8, 2024
1 parent a4b0e00 commit b09c6c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/rsgain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ static void custom_mode(int argc, char *argv[])

std::unique_ptr<ScanJob> job(ScanJob::factory(argv + optind, nb_files, config));
if (!job) {
output_fail("No valid files were specified");
output_fail("File list is not valid");
quit(EXIT_FAILURE);
}
job->scan();
Expand Down
8 changes: 7 additions & 1 deletion src/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,14 @@ ScanJob* ScanJob::factory(char **files, size_t nb_files, const Config &config)
std::unordered_set<FileType> types;
for (size_t i = 0; i < nb_files; i++) {
path = files[i];
if ((file_type = determine_filetype(path.extension().string())) == FileType::INVALID)
if (!std::filesystem::exists(path)) {
output_error("File '{}' does not exist", path.string());
return nullptr;
}
else if ((file_type = determine_filetype(path.extension().string())) == FileType::INVALID) {
output_error("File '{}' is not of a supported type", files[i]);
return nullptr;
}
else {
tracks.emplace_back(path, file_type);
types.insert(file_type);
Expand Down

0 comments on commit b09c6c9

Please sign in to comment.