diff options
author | vng <viktor.govako@gmail.com> | 2013-03-07 14:48:30 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:51:35 +0300 |
commit | 548926936703ed87ad839a78beb310c7f1ecb3de (patch) | |
tree | 510cac0049b9276b3094b0bda9561bc086f1d87b /coding | |
parent | b95ca9f18e29f4ee2c9b8b90bffbc04daf0611b5 (diff) |
Fix formatting according to code review.
Diffstat (limited to 'coding')
-rw-r--r-- | coding/coding_tests/zip_creator_test.cpp | 26 | ||||
-rw-r--r-- | coding/zip_creator.cpp | 50 |
2 files changed, 40 insertions, 36 deletions
diff --git a/coding/coding_tests/zip_creator_test.cpp b/coding/coding_tests/zip_creator_test.cpp index 8658227fef..9b96acafee 100644 --- a/coding/coding_tests/zip_creator_test.cpp +++ b/coding/coding_tests/zip_creator_test.cpp @@ -12,20 +12,22 @@ namespace { - void CreateAndTestZip(string const & filePath, string const & zipPath) - { - TEST(CreateZipFromPathDeflatedAndDefaultCompression(filePath, zipPath), ()); - vector<string> files; - ZipFileReader::FilesList(zipPath, files); - string const unzippedFile = "unzipped.tmp"; - ZipFileReader::UnzipFile(zipPath, files[0], unzippedFile); +void CreateAndTestZip(string const & filePath, string const & zipPath) +{ + TEST(CreateZipFromPathDeflatedAndDefaultCompression(filePath, zipPath), ()); + + vector<string> files; + ZipFileReader::FilesList(zipPath, files); + string const unzippedFile = "unzipped.tmp"; + ZipFileReader::UnzipFile(zipPath, files[0], unzippedFile); + + TEST(my::IsEqualFiles(filePath, unzippedFile), ()); + TEST(my::DeleteFileX(filePath), ()); + TEST(my::DeleteFileX(zipPath), ()); + TEST(my::DeleteFileX(unzippedFile), ()); +} - TEST(my::IsEqualFiles(filePath, unzippedFile), ()); - TEST(my::DeleteFileX(filePath), ()); - TEST(my::DeleteFileX(zipPath), ()); - TEST(my::DeleteFileX(unzippedFile), ()); - } } UNIT_TEST(CreateZip_BigFile) diff --git a/coding/zip_creator.cpp b/coding/zip_creator.cpp index 557b6905f3..a9a8928906 100644 --- a/coding/zip_creator.cpp +++ b/coding/zip_creator.cpp @@ -13,33 +13,35 @@ namespace { - struct ZipHandle + +struct ZipHandle +{ + zipFile m_zipFile; + ZipHandle(string const & filePath) { - zipFile m_zipFile; - ZipHandle(string const & filePath) - { - m_zipFile = zipOpen(filePath.c_str(), 0); - } - ~ZipHandle() - { - if (m_zipFile) - zipClose(m_zipFile, NULL); - } - }; - - void CreateTMZip(tm_zip & res) + m_zipFile = zipOpen(filePath.c_str(), 0); + } + ~ZipHandle() { - time_t rawtime; - struct tm * timeinfo; - time ( &rawtime ); - timeinfo = localtime ( &rawtime ); - res.tm_sec = timeinfo->tm_sec; - res.tm_min = timeinfo->tm_min; - res.tm_hour = timeinfo->tm_hour; - res.tm_mday = timeinfo->tm_mday; - res.tm_mon = timeinfo->tm_mon; - res.tm_year = timeinfo->tm_year; + if (m_zipFile) + zipClose(m_zipFile, NULL); } +}; + +void CreateTMZip(tm_zip & res) +{ + time_t rawtime; + struct tm * timeinfo; + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + res.tm_sec = timeinfo->tm_sec; + res.tm_min = timeinfo->tm_min; + res.tm_hour = timeinfo->tm_hour; + res.tm_mday = timeinfo->tm_mday; + res.tm_mon = timeinfo->tm_mon; + res.tm_year = timeinfo->tm_year; +} + } bool CreateZipFromPathDeflatedAndDefaultCompression(string const & filePath, string const & zipFilePath) |