OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "third_party/zlib/google/zip_internal.h" | 5 #include "third_party/zlib/google/zip_internal.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
31 typedef struct { | 31 typedef struct { |
32 HANDLE hf; | 32 HANDLE hf; |
33 int error; | 33 int error; |
34 } WIN32FILE_IOWIN; | 34 } WIN32FILE_IOWIN; |
35 | 35 |
36 // This function is derived from third_party/minizip/iowin32.c. | 36 // This function is derived from third_party/minizip/iowin32.c. |
37 // Its only difference is that it treats the char* as UTF8 and | 37 // Its only difference is that it treats the char* as UTF8 and |
38 // uses the Unicode version of CreateFile. | 38 // uses the Unicode version of CreateFile. |
39 void* ZipOpenFunc(void *opaque, const char* filename, int mode) { | 39 void* ZipOpenFunc(void *opaque, const char* filename, int mode) { |
40 DWORD desired_access, creation_disposition; | 40 DWORD desired_access = 0, creation_disposition = 0; |
41 DWORD share_mode, flags_and_attributes; | 41 DWORD share_mode = 0, flags_and_attributes = 0; |
42 HANDLE file = 0; | 42 HANDLE file = 0; |
43 void* ret = NULL; | 43 void* ret = NULL; |
44 | 44 |
45 desired_access = share_mode = flags_and_attributes = 0; | |
46 | |
47 if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER) == ZLIB_FILEFUNC_MODE_READ) { | 45 if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER) == ZLIB_FILEFUNC_MODE_READ) { |
48 desired_access = GENERIC_READ; | 46 desired_access = GENERIC_READ; |
49 creation_disposition = OPEN_EXISTING; | 47 creation_disposition = OPEN_EXISTING; |
50 share_mode = FILE_SHARE_READ; | 48 share_mode = FILE_SHARE_READ; |
51 } else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) { | 49 } else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) { |
52 desired_access = GENERIC_WRITE | GENERIC_READ; | 50 desired_access = GENERIC_WRITE | GENERIC_READ; |
53 creation_disposition = OPEN_EXISTING; | 51 creation_disposition = OPEN_EXISTING; |
54 } else if (mode & ZLIB_FILEFUNC_MODE_CREATE) { | 52 } else if (mode & ZLIB_FILEFUNC_MODE_CREATE) { |
55 desired_access = GENERIC_WRITE | GENERIC_READ; | 53 desired_access = GENERIC_WRITE | GENERIC_READ; |
56 creation_disposition = CREATE_ALWAYS; | 54 creation_disposition = CREATE_ALWAYS; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 0, // versionMadeBy | 369 0, // versionMadeBy |
372 LANGUAGE_ENCODING_FLAG)) { // flagBase | 370 LANGUAGE_ENCODING_FLAG)) { // flagBase |
373 DLOG(ERROR) << "Could not open zip file entry " << str_path; | 371 DLOG(ERROR) << "Could not open zip file entry " << str_path; |
374 return false; | 372 return false; |
375 } | 373 } |
376 return true; | 374 return true; |
377 } | 375 } |
378 | 376 |
379 } // namespace internal | 377 } // namespace internal |
380 } // namespace zip | 378 } // namespace zip |
OLD | NEW |