OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/unzip.h" | 5 #include "chrome/common/unzip.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "net/base/file_stream.h" | 9 #include "net/base/file_stream.h" |
10 #include "third_party/zlib/contrib/minizip/unzip.h" | 10 #include "third_party/zlib/contrib/minizip/unzip.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 return true; | 55 return true; |
56 } | 56 } |
57 // TODO(erikkay): Can we always count on the directory entry coming before a | 57 // TODO(erikkay): Can we always count on the directory entry coming before a |
58 // file in that directory? If so, then these three lines can be removed. | 58 // file in that directory? If so, then these three lines can be removed. |
59 FilePath dir = dest_file.DirName(); | 59 FilePath dir = dest_file.DirName(); |
60 if (!file_util::CreateDirectory(dir)) | 60 if (!file_util::CreateDirectory(dir)) |
61 return false; | 61 return false; |
62 | 62 |
63 net::FileStream stream; | 63 net::FileStream stream; |
64 int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE; | 64 int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE; |
65 if (stream.Open(dest_file.ToWStringHack(), flags) != 0) | 65 if (stream.Open(dest_file, flags) != 0) |
66 return false; | 66 return false; |
67 | 67 |
68 bool ret = true; | 68 bool ret = true; |
69 int num_bytes = 0; | 69 int num_bytes = 0; |
70 char buf[kUnzipBufSize]; | 70 char buf[kUnzipBufSize]; |
71 do { | 71 do { |
72 num_bytes = unzReadCurrentFile(zip_file, buf, kUnzipBufSize); | 72 num_bytes = unzReadCurrentFile(zip_file, buf, kUnzipBufSize); |
73 if (num_bytes < 0) { | 73 if (num_bytes < 0) { |
74 // If num_bytes < 0, then it's a specific UNZ_* error code. | 74 // If num_bytes < 0, then it's a specific UNZ_* error code. |
75 // While we're not currently handling these codes specifically, save | 75 // While we're not currently handling these codes specifically, save |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 LOG(WARNING) << "error %d in unzGoToNextFile"; | 192 LOG(WARNING) << "error %d in unzGoToNextFile"; |
193 ret = false; | 193 ret = false; |
194 break; | 194 break; |
195 } | 195 } |
196 } | 196 } |
197 } | 197 } |
198 unzClose(zip_file); | 198 unzClose(zip_file); |
199 return ret; | 199 return ret; |
200 } | 200 } |
201 | 201 |
OLD | NEW |