summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormilla <marc.illa@dolby.com>2021-06-15 13:12:01 +0200
committermilla <marc.illa@dolby.com>2021-06-15 13:13:12 +0200
commit8df78decb4e01b579bbbd1f479d187adf34fc030 (patch)
tree67151d234a56581e949b8d00e11c23fef166a4ff /src
parentb423f01ad10fd3cf7f860cace315c7d06e74db06 (diff)
Fix indentation
Use smart pointer for Reader Don't define fileReader constructor and destructor twice (win and posix) but just once as their implementation is the same
Diffstat (limited to 'src')
-rwxr-xr-xsrc/AS_DCP_MXF.cpp3
-rw-r--r--src/KM_fileio.cpp33
-rwxr-xr-xsrc/KM_fileio.h39
-rw-r--r--src/as-02-info.cpp3
-rwxr-xr-xsrc/asdcp-test.cpp3
-rwxr-xr-xsrc/klvwalk.cpp4
6 files changed, 34 insertions, 51 deletions
diff --git a/src/AS_DCP_MXF.cpp b/src/AS_DCP_MXF.cpp
index 9f6ca3f..5e51613 100755
--- a/src/AS_DCP_MXF.cpp
+++ b/src/AS_DCP_MXF.cpp
@@ -285,11 +285,10 @@ ASDCP::EssenceType(const std::string& filename, EssenceType_t& type, const Kumu:
else
{
DefaultLogSink().Error("Unsupported MXF Operational Pattern.\n");
- return RESULT_FORMAT;
+ return RESULT_FORMAT;
}
}
-
return result;
}
diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp
index c753012..03c3214 100644
--- a/src/KM_fileio.cpp
+++ b/src/KM_fileio.cpp
@@ -762,6 +762,16 @@ Kumu::FileWriter::Writev(const byte_t* buf, ui32_t buf_len)
return RESULT_OK;
}
+Kumu::FileReader::FileReader()
+{
+ m_Handle = INVALID_HANDLE_VALUE;
+ assert(sizeof(off_t) <= sizeof(int64_t));
+}
+
+Kumu::FileReader::~FileReader()
+{
+ Kumu::FileReader::Close();
+}
#ifdef KM_WIN32
#ifdef KM_WIN32_UTF8
@@ -816,18 +826,6 @@ Kumu::utf8_to_wbstr(const std::string& in, Kumu::ByteString& out)
//------------------------------------------------------------------------------------------
//
-Kumu::FileReader::FileReader()
-{
- m_Handle = INVALID_HANDLE_VALUE;
- assert(sizeof(off_t) <= sizeof(int64_t));
-}
-
-Kumu::FileReader::~FileReader()
-{
- Kumu::FileReader::Close();
-}
-
-Kumu::Result_t
Kumu::FileReader::OpenRead(const std::string& filename) const
{
const_cast<FileReader*>(this)->m_Filename = filename;
@@ -1077,17 +1075,6 @@ Kumu::FileWriter::Write(const byte_t* buf, ui32_t buf_len, ui32_t* bytes_written
// POSIX
//
-Kumu::FileReader::FileReader()
-{
- m_Handle = INVALID_HANDLE_VALUE;
- assert(sizeof(off_t) <= sizeof(int64_t));
-}
-
-//
-Kumu::FileReader::~FileReader()
-{
- Kumu::FileReader::Close();
-}
Kumu::Result_t
Kumu::FileReader::OpenRead(const std::string& filename) const
diff --git a/src/KM_fileio.h b/src/KM_fileio.h
index f7713fc..1ef5e75 100755
--- a/src/KM_fileio.h
+++ b/src/KM_fileio.h
@@ -67,7 +67,7 @@ namespace Kumu
};
- //
+ //
enum DirectoryEntryType_t {
DET_FILE,
DET_DIR,
@@ -84,7 +84,7 @@ namespace Kumu
KM_NO_COPY_CONSTRUCT(DirScannerEx);
public:
-
+
DirScannerEx();
~DirScannerEx() { Close(); }
@@ -133,7 +133,7 @@ namespace Kumu
//
// error: 'void Kumu::compile_time_size_checker() [with bool sizecheck = false]' previously declared here
//
- // This is happening because the equality being tested below is false. The reason for this
+ // This is happening because the equality being tested below is false. The reason for this
// will depend on your OS, but on Linux it is probably because you have not used -D_FILE_OFFSET_BITS=64
// Adding this magic macro to your CFLAGS will get you going again. If you are on a system that
// does not support 64-bit files, you can disable this check by using -DKM_SMALL_FILES_OK. You
@@ -190,7 +190,7 @@ namespace Kumu
std::string PathJoin(const std::string& Path1, const std::string& Path2, char separator = '/');
std::string PathJoin(const std::string& Path1, const std::string& Path2, const std::string& Path3, char separator = '/');
std::string PathJoin(const std::string& Path1, const std::string& Path2,
- const std::string& Path3, const std::string& Path4, char separator = '/');
+ const std::string& Path3, const std::string& Path4, char separator = '/');
//------------------------------------------------------------------------------------------
@@ -247,10 +247,10 @@ namespace Kumu
// Search all paths in SearchPaths for filenames matching Pattern (no directories are returned).
// Put results in FoundPaths. Returns after first find if one_shot is true.
PathList_t& FindInPath(const IPathMatch& Pattern, const std::string& SearchDir,
- PathList_t& FoundPaths, bool one_shot = false, char separator = '/');
+ PathList_t& FoundPaths, bool one_shot = false, char separator = '/');
PathList_t& FindInPaths(const IPathMatch& Pattern, const PathList_t& SearchPaths,
- PathList_t& FoundPaths, bool one_shot = false, char separator = '/');
+ PathList_t& FoundPaths, bool one_shot = false, char separator = '/');
std::string GetExecutablePath(const std::string& default_path);
@@ -294,7 +294,7 @@ namespace Kumu
//
// Unarchives a file into a buffer
Result_t ReadFileIntoBuffer(const std::string& Filename, Kumu::ByteString& Buffer,
- ui32_t max_size = 8 * Kumu::Megabyte);
+ ui32_t max_size = 8 * Kumu::Megabyte);
// Archives a buffer into a file
Result_t WriteBufferIntoFile(const Kumu::ByteString& Buffer, const std::string& Filename);
@@ -315,7 +315,7 @@ namespace Kumu
//------------------------------------------------------------------------------------------
//
class IFileReader
- {
+ {
public:
virtual ~IFileReader(){}
@@ -328,17 +328,17 @@ namespace Kumu
virtual bool IsOpen() const = 0; // returns true if the file is open
inline int64_t TellPosition() const // report the file pointer's location
- {
- int64_t tmp_pos;
- Tell(&tmp_pos);
- return tmp_pos;
- }
- };
+ {
+ int64_t tmp_pos;
+ Tell(&tmp_pos);
+ return tmp_pos;
+ }
+ };
//
class FileReader : public IFileReader
- {
- KM_NO_COPY_CONSTRUCT(FileReader);
+ {
+ KM_NO_COPY_CONSTRUCT(FileReader);
public:
FileReader();
@@ -350,14 +350,15 @@ namespace Kumu
virtual Result_t Tell(Kumu::fpos_t* pos) const; // report the file pointer's location
virtual Result_t Read(byte_t*, ui32_t, ui32_t* = 0) const; // read a buffer of data
- inline virtual bool IsOpen() const { // returns true if the file is open
- return (m_Handle != INVALID_HANDLE_VALUE);
+ inline virtual bool IsOpen() const // returns true if the file is open
+ {
+ return (m_Handle != INVALID_HANDLE_VALUE);
}
protected:
std::string m_Filename;
FileHandle m_Handle;
- };
+ };
//
class IFileReaderFactory
diff --git a/src/as-02-info.cpp b/src/as-02-info.cpp
index d1b823c..79fe41b 100644
--- a/src/as-02-info.cpp
+++ b/src/as-02-info.cpp
@@ -930,7 +930,7 @@ show_file_info(CommandOptions& Options, const Kumu::IFileReaderFactory& fileRead
else
{
fprintf(stderr, "Unknown/unsupported essence type: %s\n", Options.filenames.front().c_str());
- Kumu::IFileReader* Reader = fileReaderFactory.CreateFileReader();
+ ASDCP::mem_ptr<Kumu::IFileReader> Reader(fileReaderFactory.CreateFileReader());
const Dictionary* Dict = &DefaultCompositeDict();
MXF::OP1aHeader TestHeader(Dict);
@@ -957,7 +957,6 @@ show_file_info(CommandOptions& Options, const Kumu::IFileReaderFactory& fileRead
{
fputs("File is not MXF.\n", stdout);
}
- delete Reader;
}
return result;
}
diff --git a/src/asdcp-test.cpp b/src/asdcp-test.cpp
index 838d259..3b25d88 100755
--- a/src/asdcp-test.cpp
+++ b/src/asdcp-test.cpp
@@ -1870,7 +1870,7 @@ show_file_info(CommandOptions& Options, const Kumu::IFileReaderFactory& fileRead
else
{
fprintf(stderr, "File is not AS-DCP: %s\n", Options.filenames[0]);
- Kumu::IFileReader* Reader = fileReaderFactory.CreateFileReader();
+ ASDCP::mem_ptr<Kumu::IFileReader> Reader(fileReaderFactory.CreateFileReader());
const Dictionary* Dict = &DefaultCompositeDict();
MXF::OP1aHeader TestHeader(Dict);
@@ -1897,7 +1897,6 @@ show_file_info(CommandOptions& Options, const Kumu::IFileReaderFactory& fileRead
{
fputs("File is not MXF.\n", stdout);
}
- delete Reader;
}
return result;
diff --git a/src/klvwalk.cpp b/src/klvwalk.cpp
index 4e5194b..1ba9908 100755
--- a/src/klvwalk.cpp
+++ b/src/klvwalk.cpp
@@ -192,8 +192,7 @@ main(int argc, const char** argv)
for ( fi = Options.inFileList.begin(); ASDCP_SUCCESS(result) && fi != Options.inFileList.end(); fi++ )
{
- Kumu::IFileReader* Reader = defaultFactory.CreateFileReader();
-
+ ASDCP::mem_ptr<Kumu::IFileReader> Reader(defaultFactory.CreateFileReader());
if (Options.verbose_flag)
fprintf(stderr, "Opening file %s\n", ((*fi).c_str()));
@@ -350,7 +349,6 @@ main(int argc, const char** argv)
if( result == RESULT_ENDOFFILE )
result = RESULT_OK;
}
- delete Reader;
}
if ( ASDCP_FAILURE(result) )