Init basesystem source codes.
[staging/basesystem.git] / nsframework / notification_persistent_service / server / src / ns_npp_archive.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ////////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \defgroup <<Group Tag>> <<Group Name>>
19 /// \ingroup  tag_NS_NPPService
20 ///
21 ////////////////////////////////////////////////////////////////////////////////////////////////////
22
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
24 /// \ingroup  tag_NS_NPPService
25 /// \brief    This file contains the implementation for archiving and extracting files and folders.
26 ///
27 ////////////////////////////////////////////////////////////////////////////////////////////////////
28 #ifdef AGL_STUB
29 #include <other_service/strlcpy.h>
30 #endif
31
32 #include <stdio.h>
33 #include <errno.h>
34 #include <unistd.h>
35 #include <fcntl.h>
36 #include <zlib.h>
37 #include <dirent.h>
38 #include <zconf.h>
39 #include <sys/types.h>
40 #include <sys/stat.h>
41 #include <libtar_listhash.h>
42 #include <string>
43 #include <utility>
44 #include <vector>
45
46 #include "ns_npp_notificationpersistentservicelog.h"
47 #include "ns_npp_fs_directory.h"
48 #include "ns_npp_copy_worker.h"
49
50
51 tartype_t g_gztype = { (openfunc_t) OpenArchive, (closefunc_t) CloseArchive,
52                      (readfunc_t) ReadArchive, (writefunc_t) WriteArchive
53                    };
54
55 GZFiles g_gzfiles;
56
57 // CHUNK Size 256 Kb
58 // Buffer size for feeding data to and pulling data from the zlib routines
59 const size_t kChunkSize = 1U << 18;
60 // buff size 32KB
61 const size_t kBufSize = 1U << 15;
62
63 ////////////////////////////////////////////////////////////////////////////////////////////////////
64 /// CArchive
65 /// Constructor of CArchive class
66 ////////////////////////////////////////////////////////////////////////////////////////////////////
67 CCopyWorker::CArchive::CArchive() {
68 }
69
70 ////////////////////////////////////////////////////////////////////////////////////////////////////
71 /// CArchive
72 /// Destructor of CArchive class
73 ////////////////////////////////////////////////////////////////////////////////////////////////////
74 CCopyWorker::CArchive::~CArchive() {
75 }
76
77 ////////////////////////////////////////////////////////////////////////////////////////////
78 /// FolderOperation
79 /// Method to perform archive or extract operations
80 ////////////////////////////////////////////////////////////////////////////////////////////
81 EFrameworkunifiedStatus CCopyWorker::CArchive::Archive(NSP_CopyInfoCmd &f_tarchiveinfocmd,
82                                           NSP_CopyStatusResponse &f_tarchivestatusresponse) {
83   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
84   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
85   std::string l_pSourcePath = f_tarchiveinfocmd.m_csourcepath;
86   std::string l_pDestPath = f_tarchiveinfocmd.m_cdestinationpath;
87
88   if (!l_pSourcePath.empty() || !l_pDestPath.empty()) {  // LCOV_EXCL_BR_LINE 6: double check, l_pSourcePath and l_pDestPath can't be empty  // NOLINT[whitespace/line_length]
89     size_t l_ifound = l_pDestPath.rfind("/");
90     // get string from start to last occurrence of '/'. Which will return directory path
91     std::string l_cOutDirPath = l_pDestPath.substr(0, l_ifound);
92     // check for load file or release file
93     if (LOADTYPE_RELEASE == f_tarchiveinfocmd.m_eloadtype) {
94       if (CFSDirectory::DoesDirecotryExist(l_pSourcePath)) {
95         // check if destination directory exist
96         if (!CFSDirectory::DoesDirecotryExist(l_cOutDirPath)) {
97           FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "%s DOESN'T exist, Creating...",
98                  l_cOutDirPath.c_str());
99           l_estatus = CFSDirectory::CreateDirectory(l_cOutDirPath);
100         }
101         // Create archive
102         if (eFrameworkunifiedStatusOK == (l_estatus = CreateTar(l_pSourcePath, l_pDestPath,  // LCOV_EXCL_BR_LINE 6: CreateTar always return eFrameworkunifiedStatusOK  // NOLINT[whitespace/line_length]
103                                                    f_tarchivestatusresponse))) {
104           // sync tar file to persistent memory
105           SI_32 l_iTarHandle = LIBTARFAIL;
106           if (LIBTARFAIL != (l_iTarHandle = open(l_pDestPath.c_str() , O_RDONLY))) {
107             struct stat l_objStat;
108             if (-1 != fstat(l_iTarHandle , &l_objStat)) {  // LCOV_EXCL_BR_LINE 6: fstat always return ok
109               FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO3, __FUNCTION__, "Bytes written in NAND memory, %ld, file=%s", l_objStat.st_size,
110                      l_pDestPath.c_str());
111             }
112
113             close(l_iTarHandle);
114           } else {
115             l_estatus = eFrameworkunifiedStatusFail;
116           }
117         } else {
118           // LCOV_EXCL_START 6: CreateTar always return eFrameworkunifiedStatusOK
119           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
120           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Create tar Failed.");
121           l_estatus = eFrameworkunifiedStatusFail;
122           // LCOV_EXCL_STOP
123         }
124       } else {
125         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "CP_WRK_FAILURE_SRC_NOT_FND for %s ",
126                l_pSourcePath.c_str());
127         l_estatus = eFrameworkunifiedStatusFail;
128       }
129     } else {
130       // check if destination directory exist
131       if (!CFSDirectory::DoesDirecotryExist(l_pDestPath)) {
132         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "%s DOESN'T exist, Creating...",
133                l_pDestPath.c_str());
134         l_estatus = CFSDirectory::CreateDirectory(l_pDestPath);
135       }
136       if (eFrameworkunifiedStatusOK == l_estatus) {  // LCOV_EXCL_BR_LINE 6: l_estatus will be always eFrameworkunifiedStatusOK
137         // Extract archive
138         l_estatus = ExtractTar(l_pSourcePath, l_pDestPath, f_tarchivestatusresponse);
139       }
140     }
141   } else {
142     // LCOV_EXCL_START 6: double check, l_pSourcePath and l_pDestPath can't be empty
143     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
144     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source path or Dest Path empty.");
145     l_estatus = eFrameworkunifiedStatusFail;
146     // LCOV_EXCL_STOP
147   }
148   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
149   return l_estatus;
150 }
151
152
153 ////////////////////////////////////////////////////////////////////////////////////////////
154 /// CreateTar
155 /// Method to create tar
156 ////////////////////////////////////////////////////////////////////////////////////////////
157 EFrameworkunifiedStatus CCopyWorker::CArchive::CreateTar(const std::string &f_csourepath,
158                                             const std::string &f_cdestpath,
159                                             NSP_CopyStatusResponse &f_tarchivestatusresponse) {
160   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
161   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
162   std::string l_cDestPath = f_cdestpath;
163   std::string l_pcRootDirPath = f_csourepath;
164
165   libtar_list_t *l_pLibTarList = NULL;
166   l_pLibTarList = libtar_list_new(LIST_QUEUE, NULL);
167   libtar_list_add(l_pLibTarList, (void *)l_pcRootDirPath.c_str()); // NOLINT (readability/casting)
168
169   if (!l_cDestPath.empty() || !l_pcRootDirPath.empty()) {  // LCOV_EXCL_BR_LINE 6: double check, l_cDestPath and l_pcRootDirPath cannot be empty  // NOLINT[whitespace/line_length]
170     if (eFrameworkunifiedStatusOK != Create(l_cDestPath, l_pcRootDirPath, l_pLibTarList)) {  // LCOV_EXCL_BR_LINE 6: Create always return eFrameworkunifiedStatusOK  // NOLINT[whitespace/line_length]
171       // LCOV_EXCL_START 6: Create always return eFrameworkunifiedStatusOK
172       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
173       // not copied properly so remove temporary file
174       if (TRUE == CFSDirectory::RemoveDirectory(l_cDestPath)) {
175         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Delete persistent directory successful.");
176       } else {
177         FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Delete persistent directory unsuccessful.");
178       }
179       l_estatus = eFrameworkunifiedStatusFail;
180       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Archiving fails for %s to %s", l_pcRootDirPath.c_str(),
181              l_cDestPath.c_str());
182       // LCOV_EXCL_STOP
183     } else {
184       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "Folder archived %s ", l_cDestPath.c_str());
185       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,   "Source Path %s", l_pcRootDirPath.c_str());
186
187       if (TRUE == CFSDirectory::RemoveDirectory(l_pcRootDirPath)) {  // LCOV_EXCL_BR_LINE 6: always return true
188         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Delete temporary directory successful.");
189       } else {
190         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
191         FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Delete temporary directory unsuccessful.");  // LCOV_EXCL_LINE 6: always return true  // NOLINT[whitespace/line_length]
192       }
193       l_estatus = eFrameworkunifiedStatusOK;
194     }
195   } else {
196     // LCOV_EXCL_START 6: double check, l_cDestPath and l_pcRootDirPath cannot be empty
197     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
198     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source path or Dest Path empty.");
199     l_estatus = eFrameworkunifiedStatusFail;
200     // LCOV_EXCL_STOP
201   }
202   libtar_list_free(l_pLibTarList, NULL);
203   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
204   return l_estatus;
205 }
206
207 ////////////////////////////////////////////////////////////////////////////////////////////
208 /// ExtractTar
209 /// Method to extract tar
210 ////////////////////////////////////////////////////////////////////////////////////////////
211 EFrameworkunifiedStatus CCopyWorker::CArchive::ExtractTar(const std::string &f_csourepath,
212                                              const std::string &f_cdestpath,
213                                              NSP_CopyStatusResponse &f_tarchivestatusresponse) {
214   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
215   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
216   std::string l_pcTarFileDestPath = f_cdestpath;
217   std::string l_pcRootDirPath = f_csourepath;
218
219   if (!l_pcTarFileDestPath.empty() || !l_pcRootDirPath.empty()) {  // LCOV_EXCL_BR_LINE 6: double check, l_pcTarFileDestPath and l_pcRootDirPath can't be empty  // NOLINT[whitespace/line_length]
220     if (eFrameworkunifiedStatusOK != Extract(l_pcRootDirPath, l_pcTarFileDestPath)) {
221       // not copied properly so remove temporary file
222       if (TRUE == CFSDirectory::RemoveDirectory(l_pcTarFileDestPath)) {  // LCOV_EXCL_BR_LINE 6: RemoveDirectory always return true  // NOLINT[whitespace/line_length]
223         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Delete retrieved directory successful.");
224       } else {
225         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
226         FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Delete retrieved directory unsuccessful.");  // LCOV_EXCL_LINE 6: RemoveDirectory always return true  // NOLINT[whitespace/line_length]
227       }
228
229       l_estatus = eFrameworkunifiedStatusFail;
230       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "ABORT WAS CALLED!");
231       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,   "Extraction fails for %s to %s",
232              l_pcTarFileDestPath.c_str(), l_pcTarFileDestPath.c_str());
233     } else {
234       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "Folder extracted %s ", l_pcTarFileDestPath.c_str());
235       l_estatus = eFrameworkunifiedStatusOK;
236     }
237   } else {
238     // LCOV_EXCL_START 6: double check, l_pcTarFileDestPath and l_pcRootDirPath can't be empty
239     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
240     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source path or Dest Path empty.");
241     l_estatus = eFrameworkunifiedStatusFail;
242     // LCOV_EXCL_STOP
243   }
244   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
245   return l_estatus;
246 }
247
248 ////////////////////////////////////////////////////////////////////////////////////////////
249 /// Create
250 /// Method to create tar
251 ////////////////////////////////////////////////////////////////////////////////////////////
252 EFrameworkunifiedStatus CCopyWorker::CArchive::Create(std::string &f_pctarfiledestpath,
253                                          std::string &f_pcrootdirpath,
254                                          libtar_list_t *f_plibtarlist) {
255   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
256   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
257
258   if (FILEERROR == access(f_pcrootdirpath.c_str(), R_OK)) {  // LCOV_EXCL_BR_LINE 6: access always return ok
259     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
260     return eFrameworkunifiedStatusFail;  // LCOV_EXCL_LINE 6: access always return ok
261   }
262
263   TAR *l_pTarInfo = NULL;
264   CHAR l_cBuffer[MAX_PATH_LENGTH];
265   libtar_listptr_t l_pTarListPtr;
266
267   PCHAR l_pcTarFileDestPath = const_cast<PCHAR >(f_pctarfiledestpath.c_str());
268   PCHAR l_pcRootDirPath = const_cast<PCHAR >(f_pcrootdirpath.c_str());
269
270   CHAR l_temp[] = "/";
271
272   if (l_pcTarFileDestPath || l_pcRootDirPath) {  // LCOV_EXCL_BR_LINE 6: double check, l_pcTarFileDestPath and l_pcRootDirPath can't be NULL  // NOLINT[whitespace/line_length]
273     // open tar archive
274     if (LIBTARFAIL == (tar_open(&l_pTarInfo, l_pcTarFileDestPath,  &g_gztype, O_WRONLY | O_CREAT,  // LCOV_EXCL_BR_LINE 6: tar_open always return ok  // NOLINT[whitespace/line_length]
275                                 TARMODE, TAR_GNU))) {
276       // LCOV_EXCL_START 6: tar_open always return ok
277       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
278       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_open(): %s", std::strerror(errno));
279       l_estatus = eFrameworkunifiedStatusFail;
280       // LCOV_EXCL_STOP
281     }
282
283     libtar_listptr_reset(&l_pTarListPtr);
284
285     while (libtar_list_next(f_plibtarlist, &l_pTarListPtr) != LIBTARSUCCESS) {
286       if (l_pcRootDirPath[0] != '/') {  // LCOV_EXCL_BR_LINE 6: l_pcRootDirPath must begin with '/'
287         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
288         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "%s", l_pcRootDirPath);  // LCOV_EXCL_LINE 6: l_pcRootDirPath must begin with '/'  // NOLINT[whitespace/line_length]
289       } else {
290 #ifdef AGL_PosixBasedOS001LEGACY_USED
291         strlcpy(l_cBuffer, l_pcRootDirPath, sizeof(l_cBuffer));
292 #endif
293       }
294
295       if (tar_append_tree(l_pTarInfo, l_cBuffer, l_temp) != LIBTARSUCCESS) {  // LCOV_EXCL_BR_LINE 6: tar_append_tree always return ok  // NOLINT[whitespace/line_length]
296         // LCOV_EXCL_START 6: tar_append_tree always return ok
297         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
298         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__,
299                "tar_append_tree(\"%s\", \"%s\"): %s", l_cBuffer,
300                l_temp, std::strerror(errno));
301         tar_close(l_pTarInfo);
302         return eFrameworkunifiedStatusFail;
303         // LCOV_EXCL_STOP
304       }
305     }
306     if (tar_append_eof(l_pTarInfo) != LIBTARSUCCESS) {  // LCOV_EXCL_BR_LINE 6: tar_append_eof always return ok
307       // LCOV_EXCL_START 6: tar_append_eof always return ok
308       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
309       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_append_eof(): %s", std::strerror(errno));
310       tar_close(l_pTarInfo);
311       return eFrameworkunifiedStatusFail;
312       // LCOV_EXCL_STOP
313     }
314
315     if (tar_close(l_pTarInfo) != LIBTARSUCCESS) {  // LCOV_EXCL_BR_LINE 6: tar_close always return ok
316       // LCOV_EXCL_START 6: tar_close always return ok
317       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
318       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_close(): %s", std::strerror(errno));
319       l_estatus = eFrameworkunifiedStatusFail;
320       // LCOV_EXCL_STOP
321     }
322   } else {
323     // LCOV_EXCL_START 6: double check, l_pcTarFileDestPath and l_pcRootDirPath can't be NULL
324     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
325     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source path or Dest Path empty.");
326     l_estatus = eFrameworkunifiedStatusFail;
327     // LCOV_EXCL_STOP
328   }
329   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
330   return l_estatus;
331 }
332
333 ////////////////////////////////////////////////////////////////////////////////////////////
334 /// create
335 /// Method to extract tar
336 ////////////////////////////////////////////////////////////////////////////////////////////
337 EFrameworkunifiedStatus CCopyWorker::CArchive::Extract(std::string &f_pcrootdirpath, std::string &f_pctarfiledestpath) {
338   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
339   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
340
341   if (FILEERROR == access(f_pcrootdirpath.c_str(), R_OK)) {  // LCOV_EXCL_BR_LINE 6: access always return ok
342     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
343     return eFrameworkunifiedStatusFail;  // LCOV_EXCL_LINE 6: access always return ok
344   }
345
346   PCHAR l_pcRootDirPath = const_cast<PCHAR >(f_pcrootdirpath.c_str());
347   PCHAR l_pcTarFileDestPath = const_cast<PCHAR >(f_pctarfiledestpath.c_str());
348
349   TAR *l_pTarInfo = NULL;
350
351   if (l_pcRootDirPath || l_pcTarFileDestPath) {  // LCOV_EXCL_BR_LINE 6: double check, l_pcRootDirPath and l_pcTarFileDestPath can't be NULL  // NOLINT[whitespace/line_length]
352     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,   "Extraction open for %s to ", l_pcRootDirPath);
353
354     if (LIBTARFAIL == (tar_open(&l_pTarInfo, l_pcRootDirPath, &g_gztype, O_RDONLY, LIBTARSUCCESS, TAR_GNU))) {  // LCOV_EXCL_BR_LINE 6: tar_open always return ok  // NOLINT[whitespace/line_length]
355       // LCOV_EXCL_START 6: tar_open always return ok
356       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
357       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_open(): %s", std::strerror(errno));
358       l_estatus = eFrameworkunifiedStatusFail;
359       // LCOV_EXCL_STOP
360     }
361
362     if (LIBTARSUCCESS != tar_extract_all(l_pTarInfo, l_pcTarFileDestPath)) {
363       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_extract_all(): %s", std::strerror(errno));
364       l_estatus = eFrameworkunifiedStatusFail;
365     }
366
367     if (LIBTARSUCCESS != tar_close(l_pTarInfo)) {  // LCOV_EXCL_BR_LINE 6: tar_close always return ok
368       // LCOV_EXCL_START 6: tar_close always return ok
369       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
370       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_close(): %s", std::strerror(errno));
371       l_estatus = eFrameworkunifiedStatusFail;
372       // LCOV_EXCL_STOP
373     }
374   } else {
375     // LCOV_EXCL_START 6: double check, l_pcRootDirPath and l_pcTarFileDestPath can't be NULL
376     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
377     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source path or Dest Path empty.");
378     l_estatus = eFrameworkunifiedStatusFail;
379     // LCOV_EXCL_STOP
380   }
381   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
382   return l_estatus;
383 }
384
385 SI_32 OpenArchive(PCHAR f_pcpathname, SI_32 f_sioflags, SI_32 f_simode) {
386   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
387   gzFile l_gzfile = Z_NULL;
388   SI_32 l_sifiledescriptor = LIBTARFAIL;
389   if (f_pcpathname) {  // LCOV_EXCL_BR_LINE 6: double check, f_pcpathname can't be NULL
390     PCHAR l_pcgzoflags;
391
392     switch (f_sioflags & O_ACCMODE) {
393       case O_WRONLY: {
394           l_pcgzoflags = (PCHAR)"wb";
395           break;
396         }
397       case O_RDONLY: {
398           l_pcgzoflags = (PCHAR)"rb";
399           break;
400         }
401       case O_RDWR:
402       default: {
403           // LCOV_EXCL_START 6: must be O_WRONLY or O_RDONLY
404           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
405           errno = EINVAL;
406           return LIBTARFAIL;
407           // LCOV_EXCL_STOP
408         }
409     }
410
411     l_sifiledescriptor = open(f_pcpathname, f_sioflags, f_simode);
412
413     if (LIBTARFAIL == l_sifiledescriptor) {  // LCOV_EXCL_BR_LINE 6: l_sifiledescriptor always be ok
414       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
415       return LIBTARFAIL;  // LCOV_EXCL_LINE 6: l_sifiledescriptor always be ok
416     }
417
418     if (((f_sioflags & O_CREAT) && fchmod(l_sifiledescriptor, f_simode))) {  // LCOV_EXCL_BR_LINE 6: always be ok
419       // LCOV_EXCL_START 6: always be ok
420       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
421       close(l_sifiledescriptor);
422       return LIBTARFAIL;
423       // LCOV_EXCL_STOP
424     }
425
426     l_gzfile = gzdopen(l_sifiledescriptor, l_pcgzoflags);
427     if (!l_gzfile) {  // LCOV_EXCL_BR_LINE 6: l_gzfile always be not null
428       // LCOV_EXCL_START 6: l_gzfile always be not null
429       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
430       close(l_sifiledescriptor);
431
432       errno = ENOMEM;
433       return LIBTARFAIL;
434       // LCOV_EXCL_STOP
435     } else {
436       g_gzfiles.insert(std::make_pair(l_sifiledescriptor, l_gzfile));
437     }
438   } else {
439     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
440     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path empty.");  // LCOV_EXCL_LINE 6: double check, f_pcpathname can't be NULL  // NOLINT[whitespace/line_length]
441   }
442   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
443   return l_sifiledescriptor;
444 }
445
446 int CloseArchive(int fd) {
447   int     ret;
448   gzFile  gzfile = Z_NULL;
449
450   /*  checks  */
451   if (g_gzfiles.empty()) {  // LCOV_EXCL_BR_LINE 6: g_gzfiles always be not empty
452     // LCOV_EXCL_START 6: g_gzfiles always be not empty
453     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
454     errno = EBADF;
455     return -1;
456     // LCOV_EXCL_STOP
457   }
458
459   GZFiles::iterator gzfiles_it = g_gzfiles.find(fd);
460   if (gzfiles_it == g_gzfiles.end()) {  // LCOV_EXCL_BR_LINE 6: fd will always be found
461     // LCOV_EXCL_START 6: fd will always be found
462     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
463     errno = EINVAL;
464     return -1;
465     // LCOV_EXCL_STOP
466   }
467
468   /*  call zlib */
469   gzfile = gzfiles_it->second;
470   ret = gzclose(gzfile);
471
472   /*  remove gzFile* association from our list  */
473   g_gzfiles.erase(gzfiles_it);
474
475   return ret;
476 }
477
478 ssize_t ReadArchive(int fd, void *buf, size_t count) {
479   gzFile  gzfile = Z_NULL;
480
481   if (g_gzfiles.empty()) {  // LCOV_EXCL_BR_LINE 6: g_gzfiles always be not empty
482     // LCOV_EXCL_START 6: g_gzfiles always be not empty
483     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
484     errno = EBADF;
485     return -1;
486     // LCOV_EXCL_STOP
487   }
488
489   GZFiles::iterator gzfiles_it = g_gzfiles.find(fd);
490   if (gzfiles_it == g_gzfiles.end()) {  // LCOV_EXCL_BR_LINE 6: fd will always be found
491     // LCOV_EXCL_START 6: fd will always be found
492     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
493     errno = EINVAL;
494     return -1;
495     // LCOV_EXCL_STOP
496   }
497
498   gzfile = gzfiles_it->second;
499   return gzread(gzfile, buf, static_cast<UI_32>(count));
500 }
501
502 ssize_t WriteArchive(int fd, const void *buf, size_t count) {
503   gzFile  gzfile = Z_NULL;
504
505   if (g_gzfiles.empty()) {  // LCOV_EXCL_BR_LINE 6: g_gzfiles always be not empty
506     // LCOV_EXCL_START 6: g_gzfiles always be not empty
507     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
508     errno = EBADF;
509     return -1;
510     // LCOV_EXCL_STOP
511   }
512
513   GZFiles::iterator gzfiles_it = g_gzfiles.find(fd);
514   if (gzfiles_it == g_gzfiles.end()) {  // LCOV_EXCL_BR_LINE 6: fd will always be found
515     // LCOV_EXCL_START 6: fd will always be found
516     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
517     errno = EINVAL;
518     return -1;
519     // LCOV_EXCL_STOP
520   }
521
522   gzfile = gzfiles_it->second;
523   return gzwrite(gzfile, buf, static_cast<UI_32>(count));
524 }
525
526 // LCOV_EXCL_START 6: unused code
527 ////////////////////////////////////////////////////////////////////////////////////////////
528 /// FileOperationUsingLibz
529 /// Method to determine whether to compress/decompress file using libz
530 ////////////////////////////////////////////////////////////////////////////////////////////
531 EFrameworkunifiedStatus CCopyWorker::CArchive::FileOperationUsingLibz(NSP_CopyInfoCmd &f_toperainfocmd,
532                                                          NSP_CopyStatusResponse &f_toperarespstatus) {
533   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
534   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
535   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
536   std::string l_pSourcePath = f_toperainfocmd.m_csourcepath;
537   std::string l_pDestPath = f_toperainfocmd.m_cdestinationpath;
538
539   if (!l_pSourcePath.empty() || !l_pDestPath.empty()) {
540     size_t l_ifound = l_pDestPath.rfind("/");
541     // get string from start to last occurrence of '/'. Which will return directory path
542     std::string l_cOutDirPath = l_pDestPath.substr(0, l_ifound);
543
544     // check if destination directory exist
545     if (!CFSDirectory::DoesDirecotryExist(l_cOutDirPath)) {
546       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "%s DOESN'T exist, Creating...",
547              l_cOutDirPath.c_str());
548       l_estatus = CFSDirectory::CreateDirectory(l_cOutDirPath);
549     }
550
551     // check for load file or release file
552     if (LOADTYPE_RELEASE == f_toperainfocmd.m_eloadtype) {
553       // Zip
554       if (eFrameworkunifiedStatusOK == (l_estatus = CompressUsingZlib(l_pSourcePath, l_pDestPath, Z_BEST_COMPRESSION))) {
555         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "File Compression successful.");
556       } else {
557         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "File Compression failed.");
558         f_toperarespstatus.m_bpersistencechk = FALSE;
559         l_estatus = eFrameworkunifiedStatusFail;
560       }
561     } else if (LOADTYPE_LOAD == f_toperainfocmd.m_eloadtype) {
562       // Unzip
563       if (eFrameworkunifiedStatusOK == (l_estatus = DeCompressUsingZlib(l_pSourcePath, l_pDestPath))) {
564         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "File DeCompression successful.");
565       } else {
566         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "File DeCompression failed.");
567         f_toperarespstatus.m_bpersistencechk = FALSE;
568         l_estatus = eFrameworkunifiedStatusFail;
569       }
570     } else {
571       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "Wrong Request or No request for compression or decompression!");
572       l_estatus = eFrameworkunifiedStatusFail;
573     }
574   } else {
575     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path or Destination Path Empty.");
576     l_estatus = eFrameworkunifiedStatusFail;
577   }
578   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
579   return l_estatus;
580 }
581 // LCOV_EXCL_STOP
582
583 // LCOV_EXCL_START 6: unused code
584 ////////////////////////////////////////////////////////////////////////////////////////////
585 /// CompressUsingZlib
586 /// Method to compress file using libz
587 ////////////////////////////////////////////////////////////////////////////////////////////
588 EFrameworkunifiedStatus CCopyWorker::CArchive::CompressUsingZlib(const std::string &f_csourepath,
589                                                     const std::string &f_cdestpath,
590                                                     SI_32 f_iziplevel) {
591   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
592   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
593
594   if (!f_csourepath.empty() || !f_cdestpath.empty()) {
595     std::string l_cSourePath = f_csourepath;
596     std::string l_cDestPath = f_cdestpath;
597
598     std::string  l_TempFile = "";
599     l_TempFile.append(l_cDestPath.c_str());
600     l_TempFile.append(".nps_tmp");
601
602     FILE *l_pSrcFilePtr =  fopen(l_cSourePath.c_str(), "rb");
603
604     if (NULL != l_pSrcFilePtr) {
605       FILE *l_pDestFilePtr =  fopen(l_TempFile.c_str(), "wb");
606       if (NULL != l_pDestFilePtr) {
607         setvbuf(l_pSrcFilePtr, NULL, _IOFBF, kBufSize);
608         setvbuf(l_pDestFilePtr, NULL, _IOFBF, kBufSize);
609
610         // structure used to pass information to and from the zlib routines
611         z_stream l_tZstreamInfo = {};
612
613         // Allocate deflate state
614         l_tZstreamInfo.zalloc = Z_NULL;
615         l_tZstreamInfo.zfree  = Z_NULL;
616         l_tZstreamInfo.opaque = Z_NULL;
617
618         // Initialize deflates
619         SI_32 l_iDeflateStatus = deflateInit(&l_tZstreamInfo, f_iziplevel);
620
621         // Deflate Flush Status to determine end of input file
622         SI_32 l_iDeflateFlushState = Z_FINISH;
623
624         std::vector< UI_8 > l_vInBuffer(kChunkSize);
625         std::vector< UI_8 > l_vOutBuffer(kChunkSize);
626
627         // pointer to the read bytes from the input file
628         UI_8 *l_pReadBuffer =  &l_vInBuffer[0];
629         // pointer to the next available byte space to write to output file
630         UI_8 *l_pWriteBuffer = &l_vOutBuffer[0];
631
632         size_t l_uiDeflateRetData = 0;
633
634         if (Z_OK == l_iDeflateStatus) {
635           do {
636             // bytes read from input file
637             l_tZstreamInfo.avail_in = static_cast<uInt>(fread(l_pReadBuffer, 1, kChunkSize, l_pSrcFilePtr));
638
639             if (0 == ferror(l_pSrcFilePtr)) {
640               // if the eof input file reached set the flush state to Z_FINISH
641               // Z_NO_FLUSH to indicate that we still have uncompressed data
642               l_iDeflateFlushState = feof(l_pSrcFilePtr) ? Z_FINISH : Z_NO_FLUSH;
643               l_tZstreamInfo.next_in = l_pReadBuffer;
644
645               // run deflate() on input until output buffer not full, finish
646               // compression if all of source has been read in
647               do {
648                 l_tZstreamInfo.avail_out = kChunkSize;
649                 l_tZstreamInfo.next_out = l_pWriteBuffer;
650                 // no bad return value
651                 l_iDeflateStatus = deflate(&l_tZstreamInfo, l_iDeflateFlushState);
652                 // state not clobbered
653                 if (Z_STREAM_ERROR == l_iDeflateStatus) {
654                   FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "zlib stream error");
655                 } else {
656                   l_uiDeflateRetData = kChunkSize - l_tZstreamInfo.avail_out;
657                   if ((fwrite(l_pWriteBuffer, 1, l_uiDeflateRetData, l_pDestFilePtr) != l_uiDeflateRetData) ||
658                       // all data not written properly
659                       (0 != ferror(l_pDestFilePtr))) {           // file error in writing
660                     deflateEnd(&l_tZstreamInfo);
661                     l_estatus = eFrameworkunifiedStatusFail;
662                     l_tZstreamInfo.avail_out = 0;
663                     l_iDeflateFlushState = Z_FINISH;
664                   }
665                 }
666               } while (0 == l_tZstreamInfo.avail_out);  //<< check if deflate() has no more output
667             } else {                                    // by seeing that it did not fill the output buffer
668               deflateEnd(&l_tZstreamInfo);              // leaving avail_out greater than zero >>//
669               l_estatus = eFrameworkunifiedStatusFail;
670             }
671
672             // all input will be used
673             if (0 != l_tZstreamInfo.avail_in) {
674               FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "All inputs in z-stream avail_in not used");
675               l_estatus = eFrameworkunifiedStatusFail;
676             }
677             // done when last data in file processed
678           } while (Z_FINISH != l_iDeflateFlushState);
679           // stream will be complete
680           if (Z_STREAM_END != l_iDeflateStatus) {
681             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "z-stream not completed");
682             l_estatus = eFrameworkunifiedStatusFail;
683           }
684
685           FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Compressed %lu bytes down to %lu bytes",
686                  l_tZstreamInfo.total_in, l_tZstreamInfo.total_out);
687
688           FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO3, __FUNCTION__, "Bytes written in NAND memory, %lu, file=%s", l_tZstreamInfo.total_out,
689                  f_cdestpath.c_str());
690
691           // clean up and return
692           deflateEnd(&l_tZstreamInfo);
693         } else {
694           l_estatus = eFrameworkunifiedStatusFail;
695           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "deflateInit Failed");
696         }
697
698         fclose(l_pDestFilePtr);
699
700         if (0 != rename(l_TempFile.c_str(), l_cDestPath.c_str())) {
701           l_estatus = eFrameworkunifiedStatusFail;
702           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error renaming file %s to %s",
703                  l_TempFile.c_str(), l_cDestPath.c_str());
704         }
705       } else {
706         FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "Destination File Opening Error");
707         l_estatus = eFrameworkunifiedStatusFail;
708       }
709       fclose(l_pSrcFilePtr);
710     } else {
711       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "Source File Opening Error");
712       l_estatus = eFrameworkunifiedStatusFail;
713     }
714   } else {
715     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path or Destination Path Empty.");
716     l_estatus = eFrameworkunifiedStatusFail;
717   }
718
719   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
720   return l_estatus;
721 }
722 // LCOV_EXCL_STOP
723
724 // LCOV_EXCL_START 6: unused code
725 ////////////////////////////////////////////////////////////////////////////////////////////
726 /// DeCompressUsingZlib
727 /// Method to decompress file using libz
728 ////////////////////////////////////////////////////////////////////////////////////////////
729 EFrameworkunifiedStatus CCopyWorker::CArchive::DeCompressUsingZlib(const std::string &f_csourepath,
730                                                       const std::string &f_cdestpath) {
731   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
732   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
733   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
734
735   if (!f_csourepath.empty() || !f_cdestpath.empty()) {
736     std::string l_cSourePath = f_csourepath;
737     std::string l_cDestPath = f_cdestpath;
738
739     std::string  l_TempFile = "";
740     l_TempFile.append(l_cDestPath.c_str());
741     l_TempFile.append(".nps_tmp");
742
743     FILE *l_pSrcFilePtr =  fopen(l_cSourePath.c_str(), "rb");
744
745     if (NULL != l_pSrcFilePtr) {
746       FILE *l_pDestFilePtr =  fopen(l_TempFile.c_str(), "wb");
747       if (NULL != l_pDestFilePtr) {
748         setvbuf(l_pSrcFilePtr, NULL, _IOFBF, kBufSize);
749         setvbuf(l_pDestFilePtr, NULL, _IOFBF, kBufSize);
750
751         z_stream l_tZstreamInfo = {};
752
753         // allocate inflate state
754         l_tZstreamInfo.zalloc = Z_NULL;
755         l_tZstreamInfo.zfree = Z_NULL;
756         l_tZstreamInfo.opaque = Z_NULL;
757         l_tZstreamInfo.avail_in = 0;
758         l_tZstreamInfo.next_in = Z_NULL;
759
760         SI_32 l_iInflateStatus = inflateInit(&l_tZstreamInfo);
761
762         if (Z_OK == l_iInflateStatus) {
763           std::vector< UI_8 > l_vInBuffer(kChunkSize);
764           std::vector< UI_8 > l_vOutBuffer(kChunkSize);
765
766           // pointer to the read bytes from the input file
767           UI_8 *l_pReadBuffer =  &l_vInBuffer[0];
768           // pointer to the next available byte space to write to output file
769           UI_8 *l_pWriteBuffer = &l_vOutBuffer[0];
770
771           size_t l_uiDeflateRetData = 0;
772
773           do {
774             l_tZstreamInfo.avail_in = static_cast<uInt>(fread(l_pReadBuffer, 1, kChunkSize, l_pSrcFilePtr));
775             if (0 == ferror(l_pSrcFilePtr)) {
776               if (0 == l_tZstreamInfo.avail_in) {
777                 break;
778               }
779               l_tZstreamInfo.next_in = l_pReadBuffer;
780               // run inflate() on input until output buffer not full
781               do {
782                 l_tZstreamInfo.avail_out = kChunkSize;
783                 l_tZstreamInfo.next_out = l_pWriteBuffer;
784                 l_iInflateStatus = inflate(&l_tZstreamInfo, Z_NO_FLUSH);
785
786                 // state clobbered
787                 if (Z_STREAM_ERROR == l_iInflateStatus) {
788                   FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "zlib stream error");
789                   l_estatus = eFrameworkunifiedStatusFail;
790                 } else if (Z_NEED_DICT == l_iInflateStatus) {
791                   l_iInflateStatus = Z_DATA_ERROR;
792                   l_estatus = eFrameworkunifiedStatusFail;
793                 } else if (Z_MEM_ERROR == l_iInflateStatus) {
794                   inflateEnd(&l_tZstreamInfo);
795                   l_estatus = eFrameworkunifiedStatusFail;
796                   FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Out of Memory");
797                 } else {
798                   l_uiDeflateRetData = kChunkSize - l_tZstreamInfo.avail_out;
799                   // all data not written
800                   if ((fwrite(l_pWriteBuffer, 1, l_uiDeflateRetData, l_pDestFilePtr) != l_uiDeflateRetData) ||
801                       (0 != ferror(l_pDestFilePtr))) {      // or file writing error
802                     inflateEnd(&l_tZstreamInfo);
803                     l_estatus = eFrameworkunifiedStatusFail;
804                   }
805                 }
806               } while (0 == l_tZstreamInfo.avail_out);
807             } else {
808               inflateEnd(&l_tZstreamInfo);
809               l_estatus = eFrameworkunifiedStatusFail;
810             }
811
812             // done when inflate() says it's done
813           } while (Z_STREAM_END != l_iInflateStatus);
814
815           FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,   " De-compressed %lu bytes to %lu bytes",
816                  l_tZstreamInfo.total_in, l_tZstreamInfo.total_out);
817           // clean up and return
818           inflateEnd(&l_tZstreamInfo);
819         } else {
820           l_estatus = eFrameworkunifiedStatusFail;
821         }
822
823         fclose(l_pDestFilePtr);
824
825         if (0 != rename(l_TempFile.c_str(), l_cDestPath.c_str())) {
826           l_estatus = eFrameworkunifiedStatusFail;
827           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error renaming file %s to %s",
828                  l_TempFile.c_str(), l_cDestPath.c_str());
829         }
830       } else {
831         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Destination File Opening Error");
832         l_estatus = eFrameworkunifiedStatusFail;
833       }
834       fclose(l_pSrcFilePtr);
835     } else {
836       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Source File Opening Error");
837       l_estatus = eFrameworkunifiedStatusFail;
838     }
839   } else {
840     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path or Destination Path Empty.");
841     l_estatus = eFrameworkunifiedStatusFail;
842   }
843   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
844   return l_estatus;
845 }
846 // LCOV_EXCL_STOP