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

Side by Side Diff: base/file_util_win.cc

Issue 6111003: Use FilePath::DirName instead of the deprecated file_util::GetDirectoryFromPath. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review2 Created 9 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') | chrome/browser/ui/views/shell_dialogs_win.cc » ('j') | 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) 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 // No drive matched. The path does not start with a device junction 72 // No drive matched. The path does not start with a device junction
73 // that is mounted as a drive letter. This means there is no drive 73 // that is mounted as a drive letter. This means there is no drive
74 // letter path to the volume that holds |device_path|, so fail. 74 // letter path to the volume that holds |device_path|, so fail.
75 return false; 75 return false;
76 } 76 }
77 77
78 } // namespace 78 } // namespace
79 79
80 std::wstring GetDirectoryFromPath(const std::wstring& path) {
81 base::ThreadRestrictions::AssertIOAllowed();
82 wchar_t path_buffer[MAX_PATH];
83 wchar_t* file_ptr = NULL;
84 if (GetFullPathName(path.c_str(), MAX_PATH, path_buffer, &file_ptr) == 0)
85 return L"";
86
87 std::wstring::size_type length =
88 file_ptr ? file_ptr - path_buffer : path.length();
89 std::wstring directory(path, 0, length);
90 return FilePath(directory).StripTrailingSeparators().value();
91 }
92
93 bool AbsolutePath(FilePath* path) { 80 bool AbsolutePath(FilePath* path) {
94 base::ThreadRestrictions::AssertIOAllowed(); 81 base::ThreadRestrictions::AssertIOAllowed();
95 wchar_t file_path_buf[MAX_PATH]; 82 wchar_t file_path_buf[MAX_PATH];
96 if (!_wfullpath(file_path_buf, path->value().c_str(), MAX_PATH)) 83 if (!_wfullpath(file_path_buf, path->value().c_str(), MAX_PATH))
97 return false; 84 return false;
98 *path = FilePath(file_path_buf); 85 *path = FilePath(file_path_buf);
99 return true; 86 return true;
100 } 87 }
101 88
102 int CountFilesCreatedAfter(const FilePath& path, 89 int CountFilesCreatedAfter(const FilePath& path,
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 uint8 unused = *(touch + offset); 1118 uint8 unused = *(touch + offset);
1132 offset += step_size; 1119 offset += step_size;
1133 } 1120 }
1134 FreeLibrary(dll_module); 1121 FreeLibrary(dll_module);
1135 } 1122 }
1136 1123
1137 return true; 1124 return true;
1138 } 1125 }
1139 1126
1140 } // namespace file_util 1127 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util_unittest.cc ('k') | chrome/browser/ui/views/shell_dialogs_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698