From 5082fe7b5b9ea7e073e409fd8b73126951803456 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 7 Jul 2021 02:59:40 +0300 Subject: cam: Allow specifying directories in the --file option The value of the --file option is the full name of the file to which captured frames are written. To write files to a specific directory with the default naming scheme, the "frame-#.bin" name has to appear at the end of the file name. Simplify usage of the option by allowing --file to specify a directory only. If the file name ends with a '/', the default "frame-#.bin" file name is automatically appended. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/cam/buffer_writer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/cam/buffer_writer.cpp') diff --git a/src/cam/buffer_writer.cpp b/src/cam/buffer_writer.cpp index f2b21aef..a7648a92 100644 --- a/src/cam/buffer_writer.cpp +++ b/src/cam/buffer_writer.cpp @@ -49,7 +49,12 @@ int BufferWriter::write(FrameBuffer *buffer, const std::string &streamName) size_t pos; int fd, ret = 0; - filename = pattern_; + if (!pattern_.empty()) + filename = pattern_; + + if (filename.empty() || filename.back() == '/') + filename += "frame-#.bin"; + pos = filename.find_first_of('#'); if (pos != std::string::npos) { std::stringstream ss; -- cgit v1.2.1