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

Side by Side Diff: net/base/filename_util_internal.cc

Issue 1493503002: base: get rid of deprecated TrimWhitespace() function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE Created 5 years 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
« no previous file with comments | « content/renderer/npapi/webplugin_impl_unittest.cc ('k') | net/test/python_utils_unittest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "net/base/filename_util.h" 5 #include "net/base/filename_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 13 matching lines...) Expand all
24 bool replace_trailing) { 24 bool replace_trailing) {
25 const base::FilePath::CharType kReplace[] = FILE_PATH_LITERAL("-"); 25 const base::FilePath::CharType kReplace[] = FILE_PATH_LITERAL("-");
26 if (filename->empty()) 26 if (filename->empty())
27 return; 27 return;
28 if (replace_trailing) { 28 if (replace_trailing) {
29 // Handle CreateFile() stripping trailing dots and spaces on filenames 29 // Handle CreateFile() stripping trailing dots and spaces on filenames
30 // http://support.microsoft.com/kb/115827 30 // http://support.microsoft.com/kb/115827
31 size_t length = filename->size(); 31 size_t length = filename->size();
32 size_t pos = filename->find_last_not_of(FILE_PATH_LITERAL(" .")); 32 size_t pos = filename->find_last_not_of(FILE_PATH_LITERAL(" ."));
33 filename->resize((pos == std::string::npos) ? 0 : (pos + 1)); 33 filename->resize((pos == std::string::npos) ? 0 : (pos + 1));
34 #if defined(OS_WIN)
34 base::TrimWhitespace(*filename, base::TRIM_TRAILING, filename); 35 base::TrimWhitespace(*filename, base::TRIM_TRAILING, filename);
36 #else
37 base::TrimWhitespaceASCII(*filename, base::TRIM_TRAILING, filename);
38 #endif
39
35 if (filename->empty()) 40 if (filename->empty())
36 return; 41 return;
37 size_t trimmed = length - filename->size(); 42 size_t trimmed = length - filename->size();
38 if (trimmed) 43 if (trimmed)
39 filename->insert(filename->end(), trimmed, kReplace[0]); 44 filename->insert(filename->end(), trimmed, kReplace[0]);
40 } 45 }
41 base::TrimString(*filename, FILE_PATH_LITERAL("."), filename); 46 base::TrimString(*filename, FILE_PATH_LITERAL("."), filename);
42 if (filename->empty()) 47 if (filename->empty())
43 return; 48 return;
44 // Replace any path information by changing path separators. 49 // Replace any path information by changing path separators.
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 base::FilePath generated_name( 281 base::FilePath generated_name(
277 base::SysWideToNativeMB(base::UTF16ToWide(file_name))); 282 base::SysWideToNativeMB(base::UTF16ToWide(file_name)));
278 #endif 283 #endif
279 284
280 DCHECK(!generated_name.empty()); 285 DCHECK(!generated_name.empty());
281 286
282 return generated_name; 287 return generated_name;
283 } 288 }
284 289
285 } // namespace net 290 } // namespace net
OLDNEW
« no previous file with comments | « content/renderer/npapi/webplugin_impl_unittest.cc ('k') | net/test/python_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698