Skip to content

Commit 1b7fdc9

Browse files
author
Mykola Solianko
committed
cm: imagemanager: add imageunpacker itf
Signed-off-by: Mykola Solianko <[email protected]>
1 parent 45f65b1 commit 1b7fdc9

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

src/core/cm/imagemanager/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set(SOURCES imagemanager.cpp)
2020
# Headers
2121
# ######################################################################################################################
2222

23-
set(HEADERS itf/imagemanager.hpp itf/storage.hpp itf/statusnotifier.hpp imagemanager.hpp)
23+
set(HEADERS itf/imagemanager.hpp itf/imageunpacker.hpp itf/storage.hpp itf/statusnotifier.hpp imagemanager.hpp)
2424

2525
# ######################################################################################################################
2626
# Libraries
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (C) 2025 EPAM Systems, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#ifndef AOS_CORE_CM_IMAGEMANAGER_ITF_IMAGEUNPACKER_HPP_
7+
#define AOS_CORE_CM_IMAGEMANAGER_ITF_IMAGEUNPACKER_HPP_
8+
9+
#include <core/common/tools/string.hpp>
10+
11+
namespace aos::cm::imagemanager {
12+
13+
/** @addtogroup cm Communication Manager
14+
* @{
15+
*/
16+
17+
/**
18+
* Image unpacker interface.
19+
*/
20+
class ImageUnpackerItf {
21+
public:
22+
/**
23+
* Destructor.
24+
*/
25+
virtual ~ImageUnpackerItf() = default;
26+
27+
/**
28+
* Returns the size of the uncompressed file in the tar.
29+
*
30+
* @param tarPath path to the tar file.
31+
* @param filePath path to the file in the tar.
32+
* @return RetWithError<size_t>.
33+
*/
34+
virtual RetWithError<size_t> GetUncompressedFileSizeInTar(const String& tarPath, const String& filePath) = 0;
35+
36+
/**
37+
* Extracts a file from a tar.
38+
*
39+
* @param tarPath path to the tar file.
40+
* @param filePath path to the file in the tar.
41+
* @param outputPath path to the output file.
42+
* @return Error.
43+
*/
44+
virtual Error ExtractFileFromTar(const String& tarPath, const String& filePath, const String& outputPath) = 0;
45+
};
46+
47+
} // namespace aos::cm::imagemanager
48+
49+
#endif // AOS_CORE_CM_IMAGEMANAGER_ITF_IMAGEUNPACKER_HPP_
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (C) 2025 EPAM Systems, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef AOS_CORE_CM_IMAGEMANAGER_TESTS_MOCKS_IMAGEUNPACKER_HPP_
8+
#define AOS_CORE_CM_IMAGEMANAGER_TESTS_MOCKS_IMAGEUNPACKER_HPP_
9+
10+
#include <gmock/gmock.h>
11+
12+
#include <core/cm/imagemanager/itf/imageunpacker.hpp>
13+
14+
namespace aos::cm::imagemanager {
15+
16+
class MockImageUnpacker : public ImageUnpackerItf {
17+
public:
18+
MOCK_METHOD(RetWithError<size_t>, GetUncompressedFileSizeInTar, (const String& tarPath, const String& filePath),
19+
(override));
20+
MOCK_METHOD(Error, ExtractFileFromTar, (const String& tarPath, const String& filePath, const String& outputPath),
21+
(override));
22+
};
23+
24+
} // namespace aos::cm::imagemanager
25+
26+
#endif

0 commit comments

Comments
 (0)