From: Pawel Andruszkiewicz Date: Mon, 22 Jun 2015 11:32:47 +0000 (+0200) Subject: [Archive] Close the dir object first, check for error later. X-Git-Tag: submit/tizen/20150702.103311^2~2^2~27^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2a8b3471bd06060373827fd7c8c57a400a20c28a;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Archive] Close the dir object first, check for error later. Prevent CID: 451196, 451231 [Verification] TCT pass rate: 100% Change-Id: Ibc37601fed5147ecf4801e81ec53ef2b797e7b28 Signed-off-by: Pawel Andruszkiewicz --- diff --git a/src/archive/filesystem_node.cc b/src/archive/filesystem_node.cc index c00907a3..7c266d12 100755 --- a/src/archive/filesystem_node.cc +++ b/src/archive/filesystem_node.cc @@ -232,16 +232,17 @@ PlatformResult Node::getChildNames(Node::NameList* out_name_list) const } name_list.push_back(entry.d_name); } - if (0 != err) { - LoggerE("throw IOException"); - return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory."); - } if (closedir(dir) != 0) { LoggerE("throw IOException"); return PlatformResult(ErrorCode::IO_ERR, "Could not close platform node."); } + if (0 != err) { + LoggerE("throw IOException"); + return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory."); + } + *out_name_list = name_list; return PlatformResult(ErrorCode::NO_ERROR); } @@ -285,16 +286,16 @@ PlatformResult Node::getChildNodes(NodeList* out_node_list) const node_list.push_back(node); } - if (0 != err) { + if (closedir(dir) != 0) { LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms); LoggerE("throw IOException"); - return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory."); + return PlatformResult(ErrorCode::IO_ERR, "Could not close platform node."); } - if (closedir(dir) != 0) { + if (0 != err) { 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."); + return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory."); } *out_node_list = node_list;