| OLD | NEW | 
|     1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |     1 // Copyright (c) 2010 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 "base/file_util.h" |     5 #include "base/file_util.h" | 
|     6  |     6  | 
|     7 #include <windows.h> |     7 #include <windows.h> | 
|     8 #include <propvarutil.h> |     8 #include <propvarutil.h> | 
|     9 #include <psapi.h> |     9 #include <psapi.h> | 
|    10 #include <shellapi.h> |    10 #include <shellapi.h> | 
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   193       0, |   193       0, | 
|   194       FILE_SHARE_READ | FILE_SHARE_WRITE, |   194       FILE_SHARE_READ | FILE_SHARE_WRITE, | 
|   195       NULL, |   195       NULL, | 
|   196       CREATE_NEW, |   196       CREATE_NEW, | 
|   197       FILE_ATTRIBUTE_NORMAL, |   197       FILE_ATTRIBUTE_NORMAL, | 
|   198       NULL); |   198       NULL); | 
|   199   if (target_file != INVALID_HANDLE_VALUE) |   199   if (target_file != INVALID_HANDLE_VALUE) | 
|   200     ::CloseHandle(target_file); |   200     ::CloseHandle(target_file); | 
|   201   // When writing to a network share, we may not be able to change the ACLs. |   201   // When writing to a network share, we may not be able to change the ACLs. | 
|   202   // Ignore ACL errors then (REPLACEFILE_IGNORE_MERGE_ERRORS). |   202   // Ignore ACL errors then (REPLACEFILE_IGNORE_MERGE_ERRORS). | 
|   203   return ::ReplaceFile(to_path.value().c_str(), |   203   BOOL replaced = ::ReplaceFile(to_path.value().c_str(), | 
|   204       from_path.value().c_str(), NULL, |   204       from_path.value().c_str(), NULL, | 
|   205       REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL) ? true : false; |   205       REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL); | 
 |   206  | 
 |   207   if (!replaced) { | 
 |   208     DWORD replace_error = ::GetLastError(); | 
 |   209     DLOG(WARNING) << "Unable to replace file \"" << from_path.value() | 
 |   210                   << "\" with \"" << to_path.value() | 
 |   211                   << "\", error = " << replace_error | 
 |   212                   << " (" << win_util::FormatMessage(replace_error) << ")"; | 
 |   213   } | 
 |   214   return replaced ? true : false; | 
|   206 } |   215 } | 
|   207  |   216  | 
|   208 bool CopyFile(const FilePath& from_path, const FilePath& to_path) { |   217 bool CopyFile(const FilePath& from_path, const FilePath& to_path) { | 
|   209   // NOTE: I suspect we could support longer paths, but that would involve |   218   // NOTE: I suspect we could support longer paths, but that would involve | 
|   210   // analyzing all our usage of files. |   219   // analyzing all our usage of files. | 
|   211   if (from_path.value().length() >= MAX_PATH || |   220   if (from_path.value().length() >= MAX_PATH || | 
|   212       to_path.value().length() >= MAX_PATH) { |   221       to_path.value().length() >= MAX_PATH) { | 
|   213     return false; |   222     return false; | 
|   214   } |   223   } | 
|   215   return (::CopyFile(from_path.value().c_str(), to_path.value().c_str(), |   224   return (::CopyFile(from_path.value().c_str(), to_path.value().c_str(), | 
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1094       uint8 unused = *(touch + offset); |  1103       uint8 unused = *(touch + offset); | 
|  1095       offset += step_size; |  1104       offset += step_size; | 
|  1096     } |  1105     } | 
|  1097     FreeLibrary(dll_module); |  1106     FreeLibrary(dll_module); | 
|  1098   } |  1107   } | 
|  1099  |  1108  | 
|  1100   return true; |  1109   return true; | 
|  1101 } |  1110 } | 
|  1102  |  1111  | 
|  1103 }  // namespace file_util |  1112 }  // namespace file_util | 
| OLD | NEW |