summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/installer/util/lzma_util.cc18
-rw-r--r--chrome/installer/util/lzma_util.h10
2 files changed, 24 insertions, 4 deletions
diff --git a/chrome/installer/util/lzma_util.cc b/chrome/installer/util/lzma_util.cc
index b80fdd9..70e899d 100644
--- a/chrome/installer/util/lzma_util.cc
+++ b/chrome/installer/util/lzma_util.cc
@@ -105,8 +105,10 @@ DWORD LzmaUtil::OpenArchive(const std::wstring& archivePath) {
DWORD ret = NO_ERROR;
archive_handle_ = CreateFile(archivePath.c_str(), GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (archive_handle_ == INVALID_HANDLE_VALUE)
+ if (archive_handle_ == INVALID_HANDLE_VALUE) {
+ archive_handle_ = NULL; // The rest of the code only checks for NULL.
ret = GetLastError();
+ }
return ret;
}
@@ -164,11 +166,11 @@ DWORD LzmaUtil::UnPack(const std::wstring& location,
// If archive entry is directory create it and move on to the next entry.
if (f->IsDirectory) {
- file_util::CreateDirectory(file_path);
+ CreateDirectory(file_path);
continue;
}
- file_util::CreateDirectory(file_path.DirName());
+ CreateDirectory(file_path.DirName());
HANDLE hFile;
hFile = CreateFile(file_path.value().c_str(), GENERIC_WRITE, 0, NULL,
@@ -215,3 +217,13 @@ void LzmaUtil::CloseArchive() {
archive_handle_ = NULL;
}
}
+
+bool LzmaUtil::CreateDirectory(const FilePath& dir) {
+ bool ret = true;
+ if (directories_created_.find(dir.value()) == directories_created_.end()) {
+ ret = file_util::CreateDirectory(dir);
+ if (ret)
+ directories_created_.insert(dir.value());
+ }
+ return ret;
+}
diff --git a/chrome/installer/util/lzma_util.h b/chrome/installer/util/lzma_util.h
index 765bc19..86523e6 100644
--- a/chrome/installer/util/lzma_util.h
+++ b/chrome/installer/util/lzma_util.h
@@ -6,11 +6,15 @@
#define CHROME_INSTALLER_UTIL_LZMA_UTIL_H_
#pragma once
-#include <string>
#include <windows.h>
+#include <set>
+#include <string>
+
#include "base/basictypes.h"
+class FilePath;
+
// This is a utility class that acts as a wrapper around LZMA SDK library
class LzmaUtil {
public:
@@ -36,8 +40,12 @@ class LzmaUtil {
void CloseArchive();
+ protected:
+ bool CreateDirectory(const FilePath& dir);
+
private:
HANDLE archive_handle_;
+ std::set<std::wstring> directories_created_;
DISALLOW_COPY_AND_ASSIGN(LzmaUtil);
};