Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: base/file_util_win.cc

Issue 11896097: Remove GetFileCreationLocalTime. It is unused. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_util_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <psapi.h> 8 #include <psapi.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 295 }
296 296
297 bool DirectoryExists(const FilePath& path) { 297 bool DirectoryExists(const FilePath& path) {
298 base::ThreadRestrictions::AssertIOAllowed(); 298 base::ThreadRestrictions::AssertIOAllowed();
299 DWORD fileattr = GetFileAttributes(path.value().c_str()); 299 DWORD fileattr = GetFileAttributes(path.value().c_str());
300 if (fileattr != INVALID_FILE_ATTRIBUTES) 300 if (fileattr != INVALID_FILE_ATTRIBUTES)
301 return (fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0; 301 return (fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0;
302 return false; 302 return false;
303 } 303 }
304 304
305 bool GetFileCreationLocalTimeFromHandle(HANDLE file_handle,
306 LPSYSTEMTIME creation_time) {
307 base::ThreadRestrictions::AssertIOAllowed();
308 if (!file_handle)
309 return false;
310
311 FILETIME utc_filetime;
312 if (!GetFileTime(file_handle, &utc_filetime, NULL, NULL))
313 return false;
314
315 FILETIME local_filetime;
316 if (!FileTimeToLocalFileTime(&utc_filetime, &local_filetime))
317 return false;
318
319 return !!FileTimeToSystemTime(&local_filetime, creation_time);
320 }
321
322 bool GetFileCreationLocalTime(const std::wstring& filename,
323 LPSYSTEMTIME creation_time) {
324 base::ThreadRestrictions::AssertIOAllowed();
325 base::win::ScopedHandle file_handle(
326 CreateFile(filename.c_str(), GENERIC_READ, kFileShareAll, NULL,
327 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL));
328 return GetFileCreationLocalTimeFromHandle(file_handle.Get(), creation_time);
329 }
330
331 bool GetTempDir(FilePath* path) { 305 bool GetTempDir(FilePath* path) {
332 base::ThreadRestrictions::AssertIOAllowed(); 306 base::ThreadRestrictions::AssertIOAllowed();
333 307
334 wchar_t temp_path[MAX_PATH + 1]; 308 wchar_t temp_path[MAX_PATH + 1];
335 DWORD path_len = ::GetTempPath(MAX_PATH, temp_path); 309 DWORD path_len = ::GetTempPath(MAX_PATH, temp_path);
336 if (path_len >= MAX_PATH || path_len <= 0) 310 if (path_len >= MAX_PATH || path_len <= 0)
337 return false; 311 return false;
338 // TODO(evanm): the old behavior of this function was to always strip the 312 // TODO(evanm): the old behavior of this function was to always strip the
339 // trailing slash. We duplicate this here, but it shouldn't be necessary 313 // trailing slash. We duplicate this here, but it shouldn't be necessary
340 // when everyone is using the appropriate FilePath APIs. 314 // when everyone is using the appropriate FilePath APIs.
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 HANDLE cp = GetCurrentProcess(); 938 HANDLE cp = GetCurrentProcess();
965 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { 939 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) {
966 *nt_path = FilePath(mapped_file_path); 940 *nt_path = FilePath(mapped_file_path);
967 success = true; 941 success = true;
968 } 942 }
969 ::UnmapViewOfFile(file_view); 943 ::UnmapViewOfFile(file_view);
970 return success; 944 return success;
971 } 945 }
972 946
973 } // namespace file_util 947 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698