From 43d22a4f9f497c6c2b6edc822de6e8461a8a2a3a Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 27 May 2015 12:48:18 +0200 Subject: [PATCH] [Archive] Added logs in methods onEntered and onReturn Change-Id: Ibdea02869a83e7e31c9bbf151c84a5b717044a13 Signed-off-by: Piotr Kosko --- src/archive/archive_callback_data.cc | 55 +++++++++++++++ src/archive/archive_extension.cc | 5 ++ src/archive/archive_file.cc | 14 ++++ src/archive/archive_instance.cc | 4 ++ src/archive/archive_manager.cc | 1 + src/archive/archive_utils.cc | 19 +++++- src/archive/filesystem_file.cc | 1 + src/archive/filesystem_node.cc | 125 ++++++++++++++++++++++------------ src/archive/filesystem_path.cc | 4 +- src/archive/un_zip.cc | 18 ++++- src/archive/un_zip.h | 2 +- src/archive/un_zip_extract_request.cc | 11 +++ src/archive/zip.cc | 4 ++ src/archive/zip_add_request.cc | 10 +++ 14 files changed, 223 insertions(+), 50 deletions(-) diff --git a/src/archive/archive_callback_data.cc b/src/archive/archive_callback_data.cc index 8e2f859..ae0ac38 100755 --- a/src/archive/archive_callback_data.cc +++ b/src/archive/archive_callback_data.cc @@ -80,6 +80,7 @@ bool OperationCallbackData::isError() const bool OperationCallbackData::isCanceled() const { + LoggerD("Enter"); return m_is_canceled; } @@ -97,30 +98,36 @@ long OperationCallbackData::getOperationId() const void OperationCallbackData::setCallbackId(double cid) { + LoggerD("Enter"); m_cid = cid; } double OperationCallbackData::getCallbackId() const { + LoggerD("Enter"); return m_cid; } void OperationCallbackData::setHandle(long handle) { + LoggerD("Enter"); m_handle = handle; } long OperationCallbackData::getHandle() const { + LoggerD("Enter"); return m_handle; } void OperationCallbackData::setIsCanceled(bool canceled) { + LoggerD("Enter"); m_is_canceled = canceled; } void OperationCallbackData::PostMessage(const char* msg) { + LoggerD("Enter"); instance_.PostMessage(msg); } @@ -144,11 +151,13 @@ ArchiveCallbackType OperationCallbackData::getCallbackType() const ArchiveFilePtr OperationCallbackData::getArchiveFile() const { + LoggerD("Enter"); return m_caller_instance; } void OperationCallbackData::setArchiveFile(ArchiveFilePtr caller) { + LoggerD("Enter"); m_caller_instance = caller; } @@ -185,6 +194,7 @@ PlatformResult OpenCallbackData::executeOperation(ArchiveFilePtr archive_file_pt unsigned long long size = 0; PlatformResult result = node->getSize(&size); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail node->getSize()"); return result; } if (0 == size) { @@ -213,6 +223,7 @@ PlatformResult OpenCallbackData::executeOperation(ArchiveFilePtr archive_file_pt archive_file_ptr->setIsOpen(true); result = archive_file_ptr->updateListOfEntries(); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail archive_file_ptr->updateListOfEntries()"); return result; } } @@ -242,11 +253,13 @@ GetEntriesCallbackData::~GetEntriesCallbackData() ArchiveFileEntryPtrMapPtr GetEntriesCallbackData::getEntries() const { + LoggerD("Entered"); return m_entries; } void GetEntriesCallbackData::setEntries(ArchiveFileEntryPtrMapPtr entries) { + LoggerD("Entered"); m_entries = entries; } @@ -293,11 +306,13 @@ void GetEntryByNameCallbackData::setName(const std::string& name) ArchiveFileEntryPtr GetEntryByNameCallbackData::getFileEntry() const { + LoggerD("Entered"); return m_file_entry; } void GetEntryByNameCallbackData::setFileEntry(ArchiveFileEntryPtr entry) { + LoggerD("Entered"); m_file_entry = entry; } @@ -376,6 +391,8 @@ struct ProgressHolder void BaseProgressCallback::callSuccessCallbackOnMainThread() { + LoggerD("Entered"); + guint id = g_idle_add(BaseProgressCallback::callSuccessCallbackCB, static_cast(this)); if (!id) { @@ -385,6 +402,8 @@ void BaseProgressCallback::callSuccessCallbackOnMainThread() gboolean BaseProgressCallback::callSuccessCallbackCB(void* data) { + LoggerD("Entered"); + BaseProgressCallback* callback = static_cast(data); if (!callback) { LoggerE("callback pointer is NULL"); @@ -441,6 +460,8 @@ void BaseProgressCallback::callProgressCallback(long operationId, void BaseProgressCallback::callProgressCallbackOnMainThread(const double progress, ArchiveFileEntryPtr current_entry) { + LoggerD("Entered"); + ProgressHolder* ph = new(std::nothrow) ProgressHolder(); if(ph) { @@ -462,6 +483,8 @@ void BaseProgressCallback::callProgressCallbackOnMainThread(const double progres gboolean BaseProgressCallback::callProgressCallbackCB(void* data) { + LoggerD("Entered"); + ProgressHolder* ph = static_cast(data); if (!ph) { LoggerE("ph is null"); @@ -559,11 +582,13 @@ PlatformResult AddProgressCallback::executeOperation(ArchiveFilePtr archive_file ZipPtr zip; PlatformResult result = archive_file_ptr->createZipObject(&zip); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("archive_file_ptr->createZipObject()"); return result; } result = zip->addFile(callback); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("zip->addFile()"); return result; } @@ -571,6 +596,7 @@ PlatformResult AddProgressCallback::executeOperation(ArchiveFilePtr archive_file // it is needed to read entries from file result = zip->close(); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("zip->close()"); return result; } @@ -611,28 +637,36 @@ ExtractAllProgressCallback::~ExtractAllProgressCallback() filesystem::FilePtr ExtractAllProgressCallback::getDirectory() const { + LoggerD("Entered"); return m_directory; } void ExtractAllProgressCallback::setDirectory(filesystem::FilePtr directory) { + LoggerD("Entered"); m_directory = directory; } void ExtractAllProgressCallback::startedExtractingFile(unsigned long current_file_size) { + LoggerD("Entered"); + m_current_file_size = current_file_size; m_current_file_extracted_bytes = 0; } void ExtractAllProgressCallback::extractedPartOfFile(unsigned long bytes_decompressed) { + LoggerD("Entered"); + m_current_file_extracted_bytes += bytes_decompressed; updateOverallProgress(bytes_decompressed); } void ExtractAllProgressCallback::finishedExtractingFile() { + LoggerD("Entered"); + m_current_file_size = 0; m_current_file_extracted_bytes = 0; ++m_files_extracted; @@ -641,6 +675,8 @@ void ExtractAllProgressCallback::finishedExtractingFile() void ExtractAllProgressCallback::updateOverallProgress(unsigned long bytes_decompressed) { + LoggerD("Entered"); + m_overall_decompressed += bytes_decompressed; m_progress_overall = static_cast(m_overall_decompressed + m_files_extracted) / @@ -655,6 +691,8 @@ void ExtractAllProgressCallback::updateOverallProgress(unsigned long bytes_decom double ExtractAllProgressCallback::getCurrentFileProgress() const { + LoggerD("Entered"); + if(m_current_file_size > 0) { return static_cast(m_current_file_extracted_bytes) / static_cast(m_current_file_size); @@ -666,6 +704,8 @@ double ExtractAllProgressCallback::getCurrentFileProgress() const double ExtractAllProgressCallback::getOverallProgress() const { + LoggerD("Entered"); + return m_progress_overall; } @@ -677,21 +717,29 @@ PlatformResult ExtractAllProgressCallback::executeOperation(ArchiveFilePtr archi void ExtractAllProgressCallback::setExpectedDecompressedSize(unsigned long exp_dec_size) { + LoggerD("Entered"); + m_expected_decompressed_size = exp_dec_size; } unsigned long ExtractAllProgressCallback::getExpectedDecompressedSize() const { + LoggerD("Entered"); + return m_expected_decompressed_size; } void ExtractAllProgressCallback::setNumberOfFilesToExtract(unsigned long files_count) { + LoggerD("Entered"); + m_files_to_extract = files_count; } unsigned long ExtractAllProgressCallback::getNumberOfFilesToExtract() const { + LoggerD("Entered"); + return m_files_to_extract; } @@ -725,32 +773,38 @@ ExtractEntryProgressCallback::~ExtractEntryProgressCallback() ArchiveFileEntryPtr ExtractEntryProgressCallback::getArchiveFileEntry() { + LoggerD("Entered"); return m_archive_file_entry; } void ExtractEntryProgressCallback::setArchiveFileEntry(ArchiveFileEntryPtr afentry) { + LoggerD("Entered"); m_archive_file_entry = afentry; } void ExtractEntryProgressCallback::setStripName(bool strip_name) { + LoggerD("Entered"); m_strip_name = strip_name; } bool ExtractEntryProgressCallback::getStripName() const { + LoggerD("Entered"); return m_strip_name; } void ExtractEntryProgressCallback::setStripBasePath( const std::string& strip_base_path) { + LoggerD("Entered"); m_strip_base_path = strip_base_path; } const std::string& ExtractEntryProgressCallback::getStripBasePath() const { + LoggerD("Entered"); return m_strip_base_path; } @@ -771,6 +825,7 @@ PlatformResult ExtractEntryProgressCallback::executeOperation(ArchiveFilePtr arc UnZipPtr unzip; PlatformResult result = archive_file_ptr->createUnZipObject(&unzip); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("archive_file_ptr->createUnZipObject()"); return result; } diff --git a/src/archive/archive_extension.cc b/src/archive/archive_extension.cc index c774b93..710fba5 100644 --- a/src/archive/archive_extension.cc +++ b/src/archive/archive_extension.cc @@ -4,26 +4,31 @@ #include "archive_extension.h" #include "archive_instance.h" +#include "common/logger.h" // This will be generated from archive_api.js extern const char kSource_archive_api[]; common::Extension* CreateExtension() { + LoggerD("Enter"); return new ArchiveExtension; } ArchiveExtension::ArchiveExtension() { + LoggerD("Enter"); SetExtensionName("tizen.archive"); SetJavaScriptAPI(kSource_archive_api); } ArchiveExtension::~ArchiveExtension() { + LoggerD("Enter"); } common::Instance* ArchiveExtension::CreateInstance() { + LoggerD("Enter"); return new extension::archive::ArchiveInstance(); } diff --git a/src/archive/archive_file.cc b/src/archive/archive_file.cc index e9251cb..4e13109 100644 --- a/src/archive/archive_file.cc +++ b/src/archive/archive_file.cc @@ -32,6 +32,7 @@ namespace extension { namespace archive { Permission::Permission(bool r, bool w, bool rw, bool a){ + LoggerD("Enter"); permission[0] = r; permission[1] = w; permission[2] = rw; @@ -65,6 +66,7 @@ ArchiveFile::ArchiveFile(FileMode file_mode) : m_is_open(false), m_overwrite(false) { + LoggerD("Enter"); m_file_mode = file_mode; } @@ -269,6 +271,7 @@ PlatformResult ArchiveFile::addOperation(OperationCallbackData* callback) PlatformResult ArchiveFile::extractAllTask(ExtractAllProgressCallback* callback) { + LoggerD("Enter"); filesystem::FilePtr directory = callback->getDirectory(); if(!directory) { @@ -297,6 +300,7 @@ PlatformResult ArchiveFile::extractAllTask(ExtractAllProgressCallback* callback) unsigned long long size = 0; PlatformResult result = m_file->getNode()->getSize(&size); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail m_file->getNode()->getSize()"); return result; } if(size == 0) { @@ -319,6 +323,7 @@ PlatformResult ArchiveFile::extractAllTask(ExtractAllProgressCallback* callback) UnZipPtr unzip; result = createUnZipObject(&unzip); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail createUnZipObject()"); return result; } @@ -580,6 +585,7 @@ void ArchiveFile::setIsOpen(bool is_open) ArchiveFileEntryPtrMapPtr ArchiveFile::getEntryMap() const { + LoggerD("Entered"); return m_entry_map; } @@ -675,16 +681,19 @@ void ArchiveFile::setFileMode(FileMode file_mode) void ArchiveFile::setCreatedAsNewEmptyArchive(bool new_and_empty) { + LoggerD("Entered"); m_created_as_new_empty_archive = new_and_empty; } bool ArchiveFile::isCreatedAsNewEmptyArchive() const { + LoggerD("Entered"); return m_created_as_new_empty_archive; } PlatformResult ArchiveFile::updateListOfEntries() { + LoggerD("Entered"); // For explanation please see: // ArchiveFile.h m_created_as_new_empty_archive description // @@ -712,6 +721,7 @@ PlatformResult ArchiveFile::updateListOfEntries() UnZipPtr unzip; result = createUnZipObject(&unzip); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerD("Fail createUnZipObject()"); return result; } @@ -719,6 +729,7 @@ PlatformResult ArchiveFile::updateListOfEntries() ArchiveFileEntryPtrMapPtr emap; result = unzip->listEntries(&decompressedSize, &emap); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerD("Fail unzip->listEntries()"); return result; } @@ -731,6 +742,8 @@ bool ArchiveFile::isEntryWithNameInArchive(const std::string& name_in_zip, bool* out_is_directory, std::string* out_matching_name) { + LoggerD("Enter"); + if(!m_entry_map) { LoggerW("m_entry_map is NULL"); return false; @@ -763,6 +776,7 @@ bool ArchiveFile::isEntryWithNameInArchive(const std::string& name_in_zip, } if(!set_name_exists) { + LoggerE("Fail: name do not exists"); return false; } diff --git a/src/archive/archive_instance.cc b/src/archive/archive_instance.cc index 2babd02..e0ab156 100644 --- a/src/archive/archive_instance.cc +++ b/src/archive/archive_instance.cc @@ -227,6 +227,8 @@ void ArchiveInstance::Abort(const picojson::value& args, picojson::object& out) } unsigned int ConvertStringToCompressionLevel(const std::string& level) { + LoggerD("Entered"); + if (kNoCompressionStr == level) { return Z_NO_COMPRESSION; } else if (kFastCompressionStr == level) { @@ -573,6 +575,8 @@ void ArchiveInstance::Extract(const picojson::value& args, picojson::object& out } void ArchiveInstance::GetWidgetPaths(const picojson::value& args, picojson::object& out) { + LoggerD("Entered"); + std::string wgt_package_path = *(common::VirtualFs::GetInstance().GetVirtualRootDirectory(kWgtPackagePathName)); std::string wgt_private_path = diff --git a/src/archive/archive_manager.cc b/src/archive/archive_manager.cc index 8fc2428..172f10d 100644 --- a/src/archive/archive_manager.cc +++ b/src/archive/archive_manager.cc @@ -88,6 +88,7 @@ PlatformResult ArchiveManager::getPrivData(long handle, ArchiveFilePtr* archive_ *archive_file = it->second; return PlatformResult(ErrorCode::NO_ERROR); } + LoggerE("Failed: Priv is null"); return PlatformResult(ErrorCode::UNKNOWN_ERR, "Priv is null"); } diff --git a/src/archive/archive_utils.cc b/src/archive/archive_utils.cc index 09ed34d..76700da 100644 --- a/src/archive/archive_utils.cc +++ b/src/archive/archive_utils.cc @@ -32,6 +32,7 @@ using namespace filesystem; std::string bytesToReadableString(const size_t num_bytes) { + LoggerD("Enter"); std::stringstream ss; static const size_t one_mb = 1024 * 1024; static const size_t one_kb = 1024; @@ -50,6 +51,7 @@ std::string bytesToReadableString(const size_t num_bytes) PlatformResult fileModeToString(FileMode fm, std::string* fm_str) { + LoggerD("Enter"); switch(fm) { case FileMode::READ: *fm_str = "r"; @@ -64,6 +66,7 @@ PlatformResult fileModeToString(FileMode fm, std::string* fm_str) *fm_str = "a"; break; default: + LoggerE("Unknown file mode"); return PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown file mode"); } return PlatformResult(ErrorCode::NO_ERROR); @@ -71,6 +74,7 @@ PlatformResult fileModeToString(FileMode fm, std::string* fm_str) PlatformResult stringToFileMode(std::string fmString, FileMode* fm) { + LoggerD("Enter"); if (!fmString.compare("r")) { *fm = FileMode::READ; return PlatformResult(ErrorCode::NO_ERROR); @@ -89,13 +93,14 @@ PlatformResult stringToFileMode(std::string fmString, FileMode* fm) } // In widl it's "TypeMismatchError" so this exception used // instead of InvalidValues + LoggerE("Invalid FileMode"); return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Invalid FileMode"); } // FilePtr fileReferenceToFile(JSContextRef context, JSValueRef fileReference) // { // auto g_ctx = GlobalContextManager::getInstance()->getGlobalContext(context); -// +// // FilePtr file_ptr; // try { // file_ptr = JSFile::getPrivateObject(context, fileReference); @@ -111,12 +116,12 @@ PlatformResult stringToFileMode(std::string fmString, FileMode* fm) // std::string string_path = // External::fromVirtualPath(virtual_path, g_ctx); // LOGD("Path: %s", string_path.c_str()); -// +// // PathPtr path = Path::create(string_path); // NodePtr node_ptr = Node::resolve(path); // file_ptr = FilePtr(new File(node_ptr, File::PermissionList())); // } -// +// // return file_ptr; // } @@ -124,6 +129,7 @@ void getBasePathAndName(const std::string& filepath, std::string& out_basepath, std::string& out_name) { + LoggerD("Enter"); const size_t filepath_len = filepath.length(); size_t name_end_index = filepath_len; @@ -152,6 +158,7 @@ void getBasePathAndName(const std::string& filepath, std::string removeDuplicatedSlashesFromPath(const std::string& path) { + LoggerD("Enter"); const size_t path_len = path.length(); std::string out; @@ -176,6 +183,7 @@ std::string removeDuplicatedSlashesFromPath(const std::string& path) bool isDirectoryPath(const std::string& path) { + LoggerD("Enter"); if(path.empty()) { return false; } @@ -186,6 +194,7 @@ bool isDirectoryPath(const std::string& path) std::string removeTrailingDirectorySlashFromPath(const std::string& path) { + LoggerD("Enter"); if(!isDirectoryPath(path)) { return path; } @@ -195,6 +204,7 @@ std::string removeTrailingDirectorySlashFromPath(const std::string& path) std::string stripBasePathFromPath(const std::string& fullpath) { + LoggerD("Enter"); const size_t location = fullpath.find_last_of("/\\"); if(std::string::npos == location) { return fullpath; @@ -214,6 +224,7 @@ static std::string errUnknown = "Unknown error"; const std::string& getArchiveErrorMessage(int errorCode) { + LoggerD("Enter"); /** * All errors are defined in minizip library in files: * zip.h and unzip.h @@ -245,6 +256,7 @@ const std::string& getArchiveErrorMessage(int errorCode) std::string getBasePathFromPath(const std::string& fullpath) { + LoggerD("Enter"); const std::string tmp_path = removeTrailingDirectorySlashFromPath(fullpath); const size_t location = tmp_path.find_last_of("/\\"); if(std::string::npos == location) { @@ -256,6 +268,7 @@ std::string getBasePathFromPath(const std::string& fullpath) std::string getArchiveLogMessage(const int errorCode, const std::string &hint) { + LoggerD("Enter"); std::stringstream ss; ss << "Failed " << hint << " : " << getArchiveErrorMessage(errorCode) << ", " << errorCode; return std::string(ss.str()); diff --git a/src/archive/filesystem_file.cc b/src/archive/filesystem_file.cc index b714087..5691715 100644 --- a/src/archive/filesystem_file.cc +++ b/src/archive/filesystem_file.cc @@ -33,6 +33,7 @@ File::File(NodePtr node, const File::PermissionList &parentPermissions, File::~File() { + LoggerD("Enter"); } NodePtr File::getNode() const diff --git a/src/archive/filesystem_node.cc b/src/archive/filesystem_node.cc index ed9f653..581e8f9 100755 --- a/src/archive/filesystem_node.cc +++ b/src/archive/filesystem_node.cc @@ -44,6 +44,7 @@ using namespace common; #define MAX_NODE_LENGTH 256 PlatformResult Node::checkPermission(const PathPtr &path, const std::string &mode, NodeType type, bool* granted) { + LoggerD("Enter"); *granted = false; switch (type) @@ -53,12 +54,12 @@ PlatformResult Node::checkPermission(const PathPtr &path, const std::string &mod DIR* dir = opendir(path->getFullPath().c_str()); if (!dir) { - LoggerW("throw InvalidValuesException"); + LoggerE("throw InvalidValuesException"); return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Node has been deleted from platform."); } if (closedir(dir) != 0) { - LoggerW("throw InvalidValuesException"); + LoggerE("throw InvalidValuesException"); return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Could not close platform node."); } @@ -88,7 +89,7 @@ PlatformResult Node::checkPermission(const PathPtr &path, const std::string &mod *granted = true; return PlatformResult(ErrorCode::NO_ERROR); } - LoggerW("throw InvalidValuesException"); + LoggerE("throw InvalidValuesException"); return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "invalid mode"); } break; @@ -107,7 +108,7 @@ PlatformResult Node::checkPermission(const PathPtr &path, const std::string &mod } else { - LoggerW("throw InvalidValuesException"); + LoggerE("throw InvalidValuesException"); return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "invalid mode"); } @@ -138,21 +139,21 @@ PlatformResult Node::resolve(const PathPtr& path, NodePtr* node) switch (errno) { case EACCES: - LoggerW("throw InvalidValuesException for file:[%s]", path->getFullPath().c_str()); + LoggerE("throw InvalidValuesException for file:[%s]", path->getFullPath().c_str()); return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Node access denied"); break; case ENOENT: - LoggerW("throw NotFoundException for file:[%s]", path->getFullPath().c_str()); + LoggerE("throw NotFoundException for file:[%s]", path->getFullPath().c_str()); return PlatformResult(ErrorCode::NOT_FOUND_ERR, "NotFoundError"); break; default: - LoggerW("throw IOException for file:[%s]", path->getFullPath().c_str()); + LoggerE("throw IOException for file:[%s]", path->getFullPath().c_str()); return PlatformResult(ErrorCode::IO_ERR, "Platform exception fail"); } } if (!S_ISDIR(info.st_mode) & !S_ISREG(info.st_mode) && !S_ISLNK(info.st_mode)) { - LoggerW("throw IOException for file:[%s]", path->getFullPath().c_str()); + LoggerE("throw IOException for file:[%s]", path->getFullPath().c_str()); return PlatformResult(ErrorCode::IO_ERR, "Platform node is of unsupported type."); } @@ -161,6 +162,7 @@ PlatformResult Node::resolve(const PathPtr& path, NodePtr* node) if (S_ISLNK(info.st_mode)) { PlatformResult result = stat(path, &syminfo); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Error: %s", result.message().c_str()); return result; } @@ -183,6 +185,7 @@ PathPtr Node::getPath() const PlatformResult Node::getChild(const PathPtr& path, NodePtr* node) { + LoggerD("Enter"); if (m_type != NT_DIRECTORY) { LoggerW("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Not a directory."); @@ -207,19 +210,20 @@ void Node::setPermissions(int perms) PlatformResult Node::getChildNames(Node::NameList* out_name_list) const { + LoggerD("Enter"); if (m_type != NT_DIRECTORY) { - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Node is not directory."); } if ((m_perms & PERM_READ) == 0) { - LoggerW("throw InvalidValuesException"); + LoggerE("throw InvalidValuesException"); return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "No permission."); } DIR* dir = opendir(m_path->getFullPath().c_str()); if (!dir) { - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Node has been deleted from platform."); } @@ -233,12 +237,12 @@ PlatformResult Node::getChildNames(Node::NameList* out_name_list) const name_list.push_back(entry->d_name); } if (errno != 0) { - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory."); } if (closedir(dir) != 0) { - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Could not close platform node."); } @@ -248,23 +252,25 @@ PlatformResult Node::getChildNames(Node::NameList* out_name_list) const PlatformResult Node::getChildNodes(NodeList* out_node_list) const { + LoggerD("Enter"); + if (m_type != NT_DIRECTORY) { - LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); - LoggerW("throw IOException"); - LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); + LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); + LoggerE("throw IOException"); + LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); return PlatformResult(ErrorCode::IO_ERR, "Node is not directory."); } if ((m_perms & PERM_READ) == 0) { - LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); - LoggerW("throw InvalidValuesException"); + LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); + LoggerE("throw InvalidValuesException"); return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "No permission."); } DIR* dir = opendir(m_path->getFullPath().c_str()); if (!dir) { - LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); - LoggerW("throw IOException"); + LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Node has been deleted from platform."); } @@ -283,14 +289,14 @@ PlatformResult Node::getChildNodes(NodeList* out_node_list) const } if (errno != 0) { - LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); - LoggerW("throw IOException"); + LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory."); } if (closedir(dir) != 0) { - LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); - LoggerW("throw IOException"); + LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Could not close platform node."); } @@ -305,13 +311,14 @@ PlatformResult Node::createChild( NodePtr* node, int options) { + LoggerD("Enter"); if (m_type != NT_DIRECTORY) { - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Parent node is not a directory."); } if ((m_perms & PERM_WRITE) == 0) { - LoggerW("throw InvalidValuesException"); + LoggerE("throw InvalidValuesException"); return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Not enough permissions."); } @@ -319,10 +326,11 @@ PlatformResult Node::createChild( bool existed; PlatformResult result = exists(childPath, &existed); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail: exists()"); return result; } if (existed) { - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Node already exists."); } @@ -334,17 +342,18 @@ PlatformResult Node::createChild( result = createAsDirectory(childPath, node, options); break; default: - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Unsupported node type."); } if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail CreateAs...()"); return result; } if (!!(*node)) { (*node)->m_perms = m_perms; } else { - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Node creation error"); } @@ -353,6 +362,7 @@ PlatformResult Node::createChild( PlatformResult Node::remove(int options) { + LoggerD("Enter"); PlatformResult result(ErrorCode::NO_ERROR); switch (m_type) { case NT_FILE: @@ -370,21 +380,23 @@ PlatformResult Node::remove(int options) PlatformResult Node::getSize(unsigned long long* size) const { + LoggerD("Enter"); if (m_type == NT_DIRECTORY) { - LoggerW("Getting size for directories is not supported."); - LoggerW("throw IOException"); + LoggerE("Getting size for directories is not supported."); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Getting size for directories is not supported."); } struct stat info; PlatformResult result = stat(m_path, &info); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail: stat()"); return result; } if (!S_ISREG(info.st_mode)) { - LoggerW("Specified node is not a regular file."); - LoggerW("throw IOException"); + LoggerE("Specified node is not a regular file."); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Specified node is not a regular file."); } @@ -395,9 +407,11 @@ PlatformResult Node::getSize(unsigned long long* size) const PlatformResult Node::getCreated(std::time_t* time) const { + LoggerD("Enter"); struct stat info; PlatformResult result = stat(m_path, &info); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail: stat()"); return result; } *time = info.st_ctime; @@ -406,9 +420,11 @@ PlatformResult Node::getCreated(std::time_t* time) const PlatformResult Node::getModified(std::time_t* time) const { + LoggerD("Enter"); struct stat info; PlatformResult result = stat(m_path, &info); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail: stat()"); return result; } *time = info.st_mtime; @@ -418,6 +434,8 @@ PlatformResult Node::getModified(std::time_t* time) const // TODO Optimize it, maybe store a flag indicating that node is a root. PlatformResult Node::getParent(NodePtr* node) const { + LoggerD("Enter"); + // LocationPaths roots = Manager::getInstance().getLocationPaths(); // for (LocationPaths::iterator it = roots.begin(); it != roots.end(); ++it) { // if (*(*it) == *m_path) { @@ -434,6 +452,8 @@ PlatformResult Node::getParent(NodePtr* node) const PlatformResult Node::getMode(int* mode) const { + LoggerD("Enter"); + struct stat info; PlatformResult result = stat(m_path, &info); if (result.error_code() == ErrorCode::NO_ERROR) { @@ -453,6 +473,8 @@ PlatformResult Node::getMode(int* mode) const PlatformResult Node::exists(const PathPtr& path, bool* existed) { + LoggerD("Enter"); + struct stat info; memset(&info, 0, sizeof(struct stat)); int status = lstat(path->getFullPath().c_str(), &info); @@ -466,7 +488,7 @@ PlatformResult Node::exists(const PathPtr& path, bool* existed) } else if (ENAMETOOLONG == errno) { - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "file name is too long"); } else if (errno != ENOENT) @@ -479,13 +501,14 @@ PlatformResult Node::exists(const PathPtr& path, bool* existed) PlatformResult Node::stat(const PathPtr& path, struct stat* out_info) { + LoggerD("Enter"); struct stat info; memset(&info, 0, sizeof(struct stat)); if (::stat(path->getFullPath().c_str(), &info) != 0) { LoggerE("File: %s", path->getFullPath().c_str()); - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Node does not exist or no access"); } *out_info = info; @@ -497,10 +520,13 @@ Node::Node(const PathPtr& path, NodeType type): m_type(type), m_perms(PERM_NONE) { + LoggerD("Enter"); } PlatformResult Node::createAsFile(const PathPtr& path, NodePtr* node, int /* options */) { + LoggerD("Enter"); + PlatformResult result = createAsFileInternal(path); if (result.error_code() == ErrorCode::NO_ERROR) { node->reset(new Node(path, NT_FILE)); @@ -510,9 +536,11 @@ PlatformResult Node::createAsFile(const PathPtr& path, NodePtr* node, int /* opt PlatformResult Node::createAsFileInternal(const PathPtr& path) { + LoggerD("Enter"); + FILE* file = std::fopen(path->getFullPath().c_str(), "wb"); if (!file) { - LoggerW("fopen fails IOException throw for path [%s]", + LoggerE("fopen fails IOException throw for path [%s]", path->getFullPath().c_str()); return PlatformResult(ErrorCode::IO_ERR, "Platform node could not be created."); } @@ -522,6 +550,8 @@ PlatformResult Node::createAsFileInternal(const PathPtr& path) PlatformResult Node::createAsDirectory(const PathPtr& path, NodePtr* node, int options) { + LoggerD("Enter"); + // if (options & OPT_RECURSIVE) { // auto parts = Utils::getParts(path); // for (auto it = parts.begin(); it != parts.end(); ++it) { @@ -537,9 +567,11 @@ PlatformResult Node::createAsDirectory(const PathPtr& path, NodePtr* node, int o PlatformResult Node::createAsDirectoryInternal(const PathPtr& path) { + LoggerD("Enter"); + if (mkdir(path->getFullPath().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Platform node could not be created."); } return PlatformResult(ErrorCode::NO_ERROR); @@ -547,10 +579,12 @@ PlatformResult Node::createAsDirectoryInternal(const PathPtr& path) PlatformResult Node::removeAsFile(const PathPtr& path) { + LoggerD("Enter"); + auto fullPath = path->getFullPath(); if (unlink(fullPath.c_str()) != 0) { - LoggerW("remove [%s]", fullPath.c_str()); - LoggerW("throw IOException"); + LoggerE("remove [%s]", fullPath.c_str()); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Error while removing platform node."); } return PlatformResult(ErrorCode::NO_ERROR); @@ -558,11 +592,13 @@ PlatformResult Node::removeAsFile(const PathPtr& path) PlatformResult Node::removeAsDirectory(const PathPtr& path, bool recursive) { + LoggerD("Enter"); + if (recursive) { DIR* dir = opendir(path->getFullPath().c_str()); if (!dir) { - LoggerW("File %s", path->getFullPath().c_str()); - LoggerW("throw IOException"); + LoggerE("File %s", path->getFullPath().c_str()); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Node does not exist or access denied."); } errno = 0; @@ -582,6 +618,7 @@ PlatformResult Node::removeAsDirectory(const PathPtr& path, bool recursive) result = removeAsFile(subPath); } if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail: getFullPath() (%d)",result.error_code()); return result; } } @@ -592,10 +629,10 @@ PlatformResult Node::removeAsDirectory(const PathPtr& path, bool recursive) errno = 0; if (rmdir(path->getFullPath().c_str()) != 0) { if (errno == EEXIST) { - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Node has child nodes."); } - LoggerW("throw IOException"); + LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Error while removing platform node."); } @@ -604,12 +641,14 @@ PlatformResult Node::removeAsDirectory(const PathPtr& path, bool recursive) std::string Node::toUri(int /*widgetId*/) const { + LoggerD("Enter"); // TODO I believe moving this feature to WrtWrapper would make more sense. return "file://" + m_path->getFullPath(); } bool Node::isSubPath(std::string aDirPath, PathPtr aFilePath) { + LoggerD("Enter"); auto myPath = aDirPath; if(!myPath.empty() && myPath[myPath.length()-1] != Path::getSeparator()) { myPath += Path::getSeparator(); diff --git a/src/archive/filesystem_path.cc b/src/archive/filesystem_path.cc index 0e39694..955bdac 100755 --- a/src/archive/filesystem_path.cc +++ b/src/archive/filesystem_path.cc @@ -35,6 +35,7 @@ const Path::SeparatorType Path::m_pathSeparator = '/'; PathPtr Path::create(const std::string& path) { + LoggerD("Enter"); auto result = std::shared_ptr(new Path()); result->reset(path); return result; @@ -93,11 +94,12 @@ Path::Path() void Path::reset(const std::string& str) { + LoggerD("Enter"); if (!isValid(str)) { LoggerD("Invalid string %s", str.c_str()); LoggerW("throw NotFoundException"); // The only way to remove throw statement from here is to just return, because - // this function is used in the operator functions and they're not able + // this function is used in the operator functions and they're not able // to handle a PlatformResult value; return; } diff --git a/src/archive/un_zip.cc b/src/archive/un_zip.cc index 4940484..a9710be 100644 --- a/src/archive/un_zip.cc +++ b/src/archive/un_zip.cc @@ -44,12 +44,12 @@ UnZip::UnZip(const std::string& filename) : m_default_buffer_size(1024 * 1024) { LoggerD("Entered"); - m_unzip = unzOpen(filename.c_str()); } UnZip::~UnZip() { + LoggerD("Enter"); close(); } @@ -88,6 +88,7 @@ PlatformResult UnZip::open(const std::string& filename, UnZipPtr* out_unzip) PlatformResult UnZip::listEntries(unsigned long *decompressedSize, ArchiveFileEntryPtrMapPtr* out_map) { + LoggerD("Enter"); if(!m_is_open) { LoggerE("Failed to get list of entries - UnZip closed"); return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get list of files in zip archive"); @@ -165,6 +166,7 @@ PlatformResult UnZip::listEntries(unsigned long *decompressedSize, ArchiveFileEn PlatformResult UnZip::extractAllFilesTo(const std::string& extract_path, ExtractAllProgressCallback* callback) { + LoggerD("Enter"); if(!m_is_open) { LoggerE("Failed to extract files - UnZip closed"); return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to extract zip archive"); @@ -176,6 +178,7 @@ PlatformResult UnZip::extractAllFilesTo(const std::string& extract_path, unz_global_info gi; PlatformResult result = updateCallbackWithArchiveStatistics(callback, gi); if ( result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Error: %s", result.message().c_str()); return result; } @@ -184,7 +187,7 @@ PlatformResult UnZip::extractAllFilesTo(const std::string& extract_path, // int err = unzGoToFirstFile(m_unzip); if (err != UNZ_OK) { - LoggerW("%s",getArchiveLogMessage(err, "unzGoToFirstFile()").c_str()); + LoggerE("%s",getArchiveLogMessage(err, "unzGoToFirstFile()").c_str()); } for (uLong i = 0; i < gi.number_entry; i++) { @@ -196,6 +199,7 @@ PlatformResult UnZip::extractAllFilesTo(const std::string& extract_path, result = extractCurrentFile(extract_path, std::string(), callback); if ( result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail: extractCurrentFile()"); return result; } @@ -223,6 +227,7 @@ struct ExtractDataHolder PlatformResult UnZip::extractTo(ExtractEntryProgressCallback* callback) { + LoggerD("Enter"); if(!m_is_open) { LoggerE("Extract archive file entry failed - UnZip closed"); return PlatformResult(ErrorCode::UNKNOWN_ERR, "Extract archive file entry failed"); @@ -270,6 +275,7 @@ PlatformResult UnZip::extractTo(ExtractEntryProgressCallback* callback) unz_global_info gi; PlatformResult result = updateCallbackWithArchiveStatistics(callback, gi, entry_name_in_zip); if ( result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail: updateCallbackWithArchiveStatistics()"); return result; } @@ -286,6 +292,7 @@ PlatformResult UnZip::extractTo(ExtractEntryProgressCallback* callback) unsigned int matched; result = IterateFilesInZip(gi, entry_name_in_zip, callback, extractItFunction, matched, &h); if ( result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Fail: IterateFilesInZip()"); return result; } @@ -299,6 +306,7 @@ PlatformResult UnZip::extractTo(ExtractEntryProgressCallback* callback) PlatformResult UnZip::extractItFunction(const std::string& file_name, unz_file_info& file_info, void* user_data) { + LoggerD("Enter"); ExtractDataHolder* h = static_cast(user_data); if(!h) { LoggerE("ExtractDataHolder is NULL!"); @@ -309,6 +317,7 @@ PlatformResult UnZip::extractItFunction(const std::string& file_name, unz_file_i h->callback->getStripBasePath(), h->callback); if ( result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Error: %s", result.message().c_str()); return result; } @@ -322,6 +331,7 @@ PlatformResult UnZip::IterateFilesInZip(unz_global_info& gi, unsigned int& num_file_or_folder_matched, void* user_data) { + LoggerD("Enter"); int err = unzGoToFirstFile(m_unzip); if (UNZ_OK != err) { LoggerW("%s",getArchiveLogMessage(err, "unzGoToFirstFile()").c_str()); @@ -364,6 +374,7 @@ PlatformResult UnZip::IterateFilesInZip(unz_global_info& gi, if(match) { PlatformResult result = itfunc(cur_filename_in_zip, cur_file_info, user_data); if ( result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Error: %s", result.message().c_str()); return result; } ++num_file_or_folder_matched; @@ -411,6 +422,7 @@ struct ArchiveStatistics PlatformResult generateArchiveStatistics(const std::string& file_name, unz_file_info& file_info, void* user_data) { + LoggerD("Enter"); if(user_data) { ArchiveStatistics* astats = static_cast(user_data); astats->uncompressed_size += file_info.uncompressed_size; @@ -429,6 +441,7 @@ PlatformResult UnZip::updateCallbackWithArchiveStatistics(ExtractAllProgressCall unz_global_info& out_global_info, const std::string optional_filter) { + LoggerD("Enter"); int err = unzGetGlobalInfo(m_unzip, &out_global_info); if (UNZ_OK != err) { LoggerE("ret: %d",err); @@ -441,6 +454,7 @@ PlatformResult UnZip::updateCallbackWithArchiveStatistics(ExtractAllProgressCall PlatformResult result = IterateFilesInZip(out_global_info, optional_filter, callback, generateArchiveStatistics, num_matched, &astats); if ( result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Error: %s", result.message().c_str()); return result; } if(0 == num_matched) { diff --git a/src/archive/un_zip.h b/src/archive/un_zip.h index 430abd1..0b30921 100644 --- a/src/archive/un_zip.h +++ b/src/archive/un_zip.h @@ -79,7 +79,7 @@ private: const std::string& entry_name_in_zip, OperationCallbackData* callback, IterateFunction itfunc, - unsigned int& num_file_or_folder_matched, + unsigned int& num_file_or_folder_matched, void* user_data); PlatformResult updateCallbackWithArchiveStatistics(ExtractAllProgressCallback* callback, diff --git a/src/archive/un_zip_extract_request.cc b/src/archive/un_zip_extract_request.cc index 8ed2c15..1384f3c 100644 --- a/src/archive/un_zip_extract_request.cc +++ b/src/archive/un_zip_extract_request.cc @@ -39,6 +39,7 @@ using namespace common; FilePathStatus getPathStatus(const std::string& path) { + LoggerD("Enter"); if(path.empty()) { return FPS_NOT_EXIST; } @@ -59,6 +60,7 @@ FilePathStatus getPathStatus(const std::string& path) void divideToPathAndName(const std::string& filepath, std::string& out_path, std::string& out_name) { + LoggerD("Enter"); size_t pos_last_dir = filepath.find_last_of("/\\"); if(pos_last_dir == std::string::npos) { out_path = ""; @@ -71,6 +73,7 @@ void divideToPathAndName(const std::string& filepath, std::string& out_path, void createMissingDirectories(const std::string& path, bool check_first = true) { + LoggerD("Enter"); if(check_first) { const FilePathStatus path_status = getPathStatus(path); //LoggerD("[%s] status: %d", path.c_str(), path_status); @@ -105,6 +108,7 @@ void createMissingDirectories(const std::string& path, bool check_first = true) void changeFileAccessAndModifyDate(const std::string& filepath, tm_unz tmu_date) { + LoggerD("Enter"); struct utimbuf ut; struct tm newdate; newdate.tm_sec = tmu_date.tm_sec; @@ -130,6 +134,7 @@ PlatformResult UnZipExtractRequest::execute(UnZip& owner, const std::string& ext const std::string& base_strip_path, BaseProgressCallback* callback) { + LoggerD("Enter"); UnZipExtractRequest req(owner, extract_path, base_strip_path, callback); if(!req.m_callback){ LoggerE("Callback is null"); @@ -156,6 +161,7 @@ UnZipExtractRequest::UnZipExtractRequest(UnZip& owner, m_is_directory_entry(false) { + LoggerD("Enter"); } PlatformResult UnZipExtractRequest::run() @@ -164,6 +170,7 @@ PlatformResult UnZipExtractRequest::run() PlatformResult result = getCurrentFileInfo(); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Error: %s", result.message().c_str()); return result; } @@ -178,6 +185,8 @@ PlatformResult UnZipExtractRequest::run() UnZipExtractRequest::~UnZipExtractRequest() { + LoggerD("Enter"); + if(m_output_file) { fclose(m_output_file); m_output_file = NULL; @@ -360,10 +369,12 @@ PlatformResult UnZipExtractRequest::prepareOutputSubdirectory() filesystem::NodePtr node; PlatformResult result = filesystem::Node::resolve(path, &node); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Error: %s", result.message().c_str()); return result; } result = node->remove(filesystem::OPT_RECURSIVE); if (result.error_code() != ErrorCode::NO_ERROR) { + LoggerE("Error: %s", result.message().c_str()); return result; } } diff --git a/src/archive/zip.cc b/src/archive/zip.cc index 354ade9..e235190 100644 --- a/src/archive/zip.cc +++ b/src/archive/zip.cc @@ -38,6 +38,8 @@ using namespace common; void Zip::generateZipFileInfo(const std::string& filename, zip_fileinfo& out_zi) { + LoggerD("Enter"); + memset(&out_zi, 0, sizeof(zip_fileinfo)); time_t tm_t = 0; @@ -85,6 +87,8 @@ Zip::Zip(const std::string& filename, ZipOpenMode open_mode) : Zip::~Zip() { + LoggerD("Enter"); + close(); } diff --git a/src/archive/zip_add_request.cc b/src/archive/zip_add_request.cc index bbda2ff..5a52867 100644 --- a/src/archive/zip_add_request.cc +++ b/src/archive/zip_add_request.cc @@ -39,10 +39,13 @@ ZipAddRequest::ZipAddRequest(Zip& owner, AddProgressCallback*& callback) : m_compression_level(0), m_new_file_in_zip_opened(false) { + LoggerD("Enter"); + } ZipAddRequest::~ZipAddRequest() { + LoggerD("Enter"); if(m_input_file) { fclose(m_input_file); m_input_file = NULL; @@ -62,12 +65,14 @@ ZipAddRequest::~ZipAddRequest() PlatformResult ZipAddRequest::execute(Zip& owner, AddProgressCallback*& callback) { + LoggerD("Enter"); ZipAddRequest req(owner, callback); return req.run(); } PlatformResult ZipAddRequest::run() { + LoggerD("Enter"); if(!m_callback) { LoggerE("m_callback is NULL"); return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add file(-s) to archive"); @@ -186,6 +191,7 @@ PlatformResult ZipAddRequest::run() void ZipAddRequest::addNodeAndSubdirsToList(filesystem::NodePtr src_node, filesystem::NodeList& out_list_of_child_nodes) { + LoggerD("Enter"); out_list_of_child_nodes.push_back(src_node); if(filesystem::NT_DIRECTORY == src_node->getType()) { @@ -286,6 +292,7 @@ PlatformResult ZipAddRequest::addEmptyDirectoryToZipArchive(std::string name_in_ PlatformResult ZipAddRequest::addToZipArchive(filesystem::NodePtr src_file_node) { + LoggerD("Enter"); const std::string name_in_zip = getNameInZipArchiveFor(src_file_node, m_callback->getFileEntry()->getStriped()); const std::string src_file_path = src_file_node->getPath()->getFullPath(); @@ -466,6 +473,7 @@ PlatformResult ZipAddRequest::addToZipArchive(filesystem::NodePtr src_file_node) std::string removeDirCharsFromFront(const std::string& path) { + LoggerD("Enter"); for(size_t i = 0; i < path.length(); ++i) { const char& cur = path[i]; if(cur != '/' && cur != '\\') { @@ -478,6 +486,7 @@ std::string removeDirCharsFromFront(const std::string& path) std::string generateFullPathForZip(const std::string& path) { + LoggerD("Enter"); //Step 1: Remove / from begining const size_t path_len = path.length(); @@ -513,6 +522,7 @@ std::string generateFullPathForZip(const std::string& path) std::string ZipAddRequest::getNameInZipArchiveFor(filesystem::NodePtr node, bool strip) { + LoggerD("Enter"); const std::string node_full_path = node->getPath()->getFullPath(); std::string cut_path; -- 2.7.4