diff options
author | Stefan Pöschel <github@basicmaster.de> | 2018-02-16 13:48:42 +0100 |
---|---|---|
committer | Stefan Pöschel <github@basicmaster.de> | 2018-02-16 13:48:42 +0100 |
commit | f2c65be1036bb5d7310c4a8714e14bb4496efebb (patch) | |
tree | 10a2d430ed112edb52419652d5060a24e2ea23ea /src/odr-padenc.cpp | |
parent | 6d7667155dca929544fbcc362286df2618ed60d0 (diff) | |
download | ODR-PadEnc-f2c65be1036bb5d7310c4a8714e14bb4496efebb.tar.gz ODR-PadEnc-f2c65be1036bb5d7310c4a8714e14bb4496efebb.tar.bz2 ODR-PadEnc-f2c65be1036bb5d7310c4a8714e14bb4496efebb.zip |
SLS: add support to request slides dir re-read
A re-read of the slides dir can now be requested by storing a file named
`REQUEST_SLIDES_DIR_REREAD` into the slides dir. When the next slide is
going to be encoded and this file is present, the slides dir is re-read
and this file is deleted.
Diffstat (limited to 'src/odr-padenc.cpp')
-rw-r--r-- | src/odr-padenc.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/odr-padenc.cpp b/src/odr-padenc.cpp index 94f3d68..461502e 100644 --- a/src/odr-padenc.cpp +++ b/src/odr-padenc.cpp @@ -350,8 +350,26 @@ int PadEncoder::EncodeSlide(bool skip_if_already_queued) { return 0; } + // check for slides dir re-read request + std::string request_reread_path = std::string(options.sls_dir) + "/" + SLSEncoder::REQUEST_REREAD_FILENAME; + struct stat request_reread_stat; + if (stat(request_reread_path.c_str(), &request_reread_stat)) { + // ignore missing request file + if (errno != ENOENT) { + perror("ODR-PadEnc Error: could not retrieve slides dir re-read request file stat"); + return 1; + } + } else { + // handle request + fprintf(stderr, "ODR-PadEnc received slides dir re-read request!\n"); + if (unlink(request_reread_path.c_str())) + perror(("ODR-PadEnc Error: erasing file '" + request_reread_path +"' failed").c_str()); + + slides.Clear(); + } + // usually invoked once - for(;;) { + for (;;) { // try to read slides dir (if present) if (slides.Empty()) { if (!slides.InitFromDir(options.sls_dir)) @@ -366,7 +384,7 @@ int PadEncoder::EncodeSlide(bool skip_if_already_queued) { if (sls_encoder.encodeSlide(slide.filepath, slide.fidx, options.raw_slides)) { slides_success = true; if (options.erase_after_tx) { - if (unlink(slide.filepath.c_str()) == -1) + if (unlink(slide.filepath.c_str())) perror(("ODR-PadEnc Error: erasing file '" + slide.filepath +"' failed").c_str()); } } else { |