diff --git a/lib/src/subtitle.cpp b/lib/src/subtitle.cpp index bbcf17c..aee7e3b 100644 --- a/lib/src/subtitle.cpp +++ b/lib/src/subtitle.cpp @@ -30,12 +30,16 @@ subtitle::subtitle(const filesystem::path &sp, RW rw) { if (sp.empty()) { this->file_path = sp; } else { + if(!filesystem::exists(sp.parent_path())) { + log::debug("Directory ({}) doesn't exist - creating it", sp.parent_path()); + filesystem::create_directory(sp.parent_path()); + } this->file_path = weakly_canonical(sp); this->filename = new string(this->file_path.filename().generic_string()); this->subtitle_file = new fstream(this->file_path.c_str(), fstream::ate | fstream::out | fstream::trunc); + } - } } diff --git a/lib/src/video.cpp b/lib/src/video.cpp index a317cff..d5ce290 100644 --- a/lib/src/video.cpp +++ b/lib/src/video.cpp @@ -230,7 +230,7 @@ frame_header *video::read_steg_header(AVFrame *fr) { if (regex_match(found_header, frame_header::header_regex)) { break; } else if (count == 2) { - log::info("Found frame_header '{}' should be |L|", found_header); + log::debug("Found frame_header '{}' should be |L|", found_header); assert(found_header == "|L|"); } @@ -968,7 +968,7 @@ bool video::has_steg_file() { break; } if (ret >= 0) { - log::info("Finding a frame_header from frame: {}, {}", this->read_x, this->read_y); + log::debug("Finding a frame_header from frame: {}, {}", this->read_x, this->read_y); frame_header *h = this->read_steg_header(picture); if (h != nullptr) { log::debug("Setting frame_header: {}", h->to_string()); diff --git a/lib/test/src/TestSubtitleFile.cpp b/lib/test/src/TestSubtitleFile.cpp index 7f65596..e14db18 100644 --- a/lib/test/src/TestSubtitleFile.cpp +++ b/lib/test/src/TestSubtitleFile.cpp @@ -100,8 +100,10 @@ TEST_CASE("Subtitle file can write lines out") { string write_file("output/gen_subs.srt"); subtitle *write_sub = new subtitle(write_file, RW::WRITE); - write_sub->write_line(input); - write_sub->write_line(input2); + int ret = write_sub->write_line(input); + REQUIRE(ret == 0); + ret = write_sub->write_line(input2); + REQUIRE(ret == 0); std::ifstream output(write_file); diff --git a/lib/test/src/TestVideoFile.cpp b/lib/test/src/TestVideoFile.cpp index 5f036cc..8e88da9 100644 --- a/lib/test/src/TestVideoFile.cpp +++ b/lib/test/src/TestVideoFile.cpp @@ -24,7 +24,7 @@ void compare_files(const std::string &f, const std::string& s) { log::error("O: {}", second_line); } - assert(first_line == second_line); + REQUIRE(first_line == second_line); } first->clear(); @@ -43,7 +43,7 @@ void input_equals_output(string i_video, const string& o_video, string i_subtitl video *o_v = new video(o_video, o_sub); i_v->write_subtitle_file(); - assert(o_v->has_steg_file()); + REQUIRE(o_v->has_steg_file()); o_v->read_subtitle_file(); compare_files(i_subtitle, o_subtitle);