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

Side by Side Diff: base/file_util.cc

Issue 8991: Always show file extensions in the shelf. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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.h ('k') | chrome/browser/views/download_item_view.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <fstream> 9 #include <fstream>
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 std::wstring::size_type last_sep = path->find_last_of(kPathSeparator); 82 std::wstring::size_type last_sep = path->find_last_of(kPathSeparator);
83 if (last_sep != std::wstring::npos) 83 if (last_sep != std::wstring::npos)
84 path->resize(last_sep); 84 path->resize(last_sep);
85 } 85 }
86 } 86 }
87 87
88 std::wstring GetFilenameFromPath(const std::wstring& path) { 88 std::wstring GetFilenameFromPath(const std::wstring& path) {
89 // TODO(erikkay): fix this - it's not using kPathSeparator, but win unit test 89 // TODO(erikkay): fix this - it's not using kPathSeparator, but win unit test
90 // are exercising '/' as a path separator as well. 90 // are exercising '/' as a path separator as well.
91 std::wstring::size_type pos = path.find_last_of(L"\\/"); 91 std::wstring::size_type pos = path.find_last_of(L"\\/");
92 return std::wstring(path, pos == std::wstring::npos ? 0 : pos+1); 92 return std::wstring(path, pos == std::wstring::npos ? 0 : pos + 1);
93 } 93 }
94 94
95 std::wstring GetFileExtensionFromPath(const std::wstring& path) { 95 std::wstring GetFileExtensionFromPath(const std::wstring& path) {
96 std::wstring file_name = GetFilenameFromPath(path); 96 std::wstring file_name = GetFilenameFromPath(path);
97 std::wstring::size_type last_dot = file_name.rfind(L'.'); 97 std::wstring::size_type last_dot = file_name.rfind(L'.');
98 return std::wstring(last_dot == std::wstring::npos? L"" : file_name, last_dot+ 1); 98 return std::wstring(last_dot == std::wstring::npos ?
99 L"" :
100 file_name, last_dot+1);
101 }
102
103 std::wstring GetFilenameWithoutExtensionFromPath(const std::wstring& path) {
104 std::wstring file_name = GetFilenameFromPath(path);
105 std::wstring::size_type last_dot = file_name.rfind(L'.');
106 return file_name.substr(0, last_dot);
99 } 107 }
100 108
101 void AppendToPath(std::wstring* path, const std::wstring& new_ending) { 109 void AppendToPath(std::wstring* path, const std::wstring& new_ending) {
102 if (!path) { 110 if (!path) {
103 NOTREACHED(); 111 NOTREACHED();
104 return; // Don't crash in this function in release builds. 112 return; // Don't crash in this function in release builds.
105 } 113 }
106 114
107 if (!EndsWithSeparator(path)) 115 if (!EndsWithSeparator(path))
108 path->push_back(kPathSeparator); 116 path->push_back(kPathSeparator);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 303 }
296 304
297 bool CloseFile(FILE* file) { 305 bool CloseFile(FILE* file) {
298 if (file == NULL) 306 if (file == NULL)
299 return true; 307 return true;
300 return fclose(file) == 0; 308 return fclose(file) == 0;
301 } 309 }
302 310
303 } // namespace 311 } // namespace
304 312
OLDNEW
« no previous file with comments | « base/file_util.h ('k') | chrome/browser/views/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698