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

Side by Side Diff: base/file_util_win.cc

Issue 13196006: Move path functions from file_util to FilePath object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
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 19 matching lines...) Expand all
30 30
31 namespace file_util { 31 namespace file_util {
32 32
33 namespace { 33 namespace {
34 34
35 const DWORD kFileShareAll = 35 const DWORD kFileShareAll =
36 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; 36 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
37 37
38 } // namespace 38 } // namespace
39 39
40 bool AbsolutePath(FilePath* path) {
41 base::ThreadRestrictions::AssertIOAllowed();
42 wchar_t file_path_buf[MAX_PATH];
43 if (!_wfullpath(file_path_buf, path->value().c_str(), MAX_PATH))
44 return false;
45 *path = FilePath(file_path_buf);
46 return true;
47 }
48
49 int CountFilesCreatedAfter(const FilePath& path, 40 int CountFilesCreatedAfter(const FilePath& path,
50 const base::Time& comparison_time) { 41 const base::Time& comparison_time) {
51 base::ThreadRestrictions::AssertIOAllowed(); 42 base::ThreadRestrictions::AssertIOAllowed();
52 43
53 int file_count = 0; 44 int file_count = 0;
54 FILETIME comparison_filetime(comparison_time.ToFileTime()); 45 FILETIME comparison_filetime(comparison_time.ToFileTime());
55 46
56 WIN32_FIND_DATA find_file_data; 47 WIN32_FIND_DATA find_file_data;
57 // All files in given dir 48 // All files in given dir
58 std::wstring filename_spec = path.Append(L"*").value(); 49 std::wstring filename_spec = path.Append(L"*").value();
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 884
894 // Length of |path| with path separator appended. 885 // Length of |path| with path separator appended.
895 size_t prefix = path.StripTrailingSeparators().value().size() + 1; 886 size_t prefix = path.StripTrailingSeparators().value().size() + 1;
896 // The whole path string must be shorter than MAX_PATH. That is, it must be 887 // The whole path string must be shorter than MAX_PATH. That is, it must be
897 // prefix + component_length < MAX_PATH (or equivalently, <= MAX_PATH - 1). 888 // prefix + component_length < MAX_PATH (or equivalently, <= MAX_PATH - 1).
898 int whole_path_limit = std::max(0, MAX_PATH - 1 - static_cast<int>(prefix)); 889 int whole_path_limit = std::max(0, MAX_PATH - 1 - static_cast<int>(prefix));
899 return std::min(whole_path_limit, static_cast<int>(max_length)); 890 return std::min(whole_path_limit, static_cast<int>(max_length));
900 } 891 }
901 892
902 } // namespace file_util 893 } // namespace file_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698