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

Side by Side Diff: webrtc/base/pathutils.cc

Issue 2572703002: Delete method Pathname::url and base/urlencode* (Closed)
Patch Set: Created 4 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 | « webrtc/base/pathutils.h ('k') | webrtc/base/pathutils_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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #if defined(WEBRTC_WIN) 11 #if defined(WEBRTC_WIN)
12 #include "webrtc/base/win32.h" 12 #include "webrtc/base/win32.h"
13 #include <shellapi.h> 13 #include <shellapi.h>
14 #include <shlobj.h> 14 #include <shlobj.h>
15 #include <tchar.h> 15 #include <tchar.h>
16 #endif // WEBRTC_WIN 16 #endif // WEBRTC_WIN
17 17
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/base/fileutils.h" 19 #include "webrtc/base/fileutils.h"
20 #include "webrtc/base/logging.h" 20 #include "webrtc/base/logging.h"
21 #include "webrtc/base/pathutils.h" 21 #include "webrtc/base/pathutils.h"
22 #include "webrtc/base/stringutils.h" 22 #include "webrtc/base/stringutils.h"
23 #include "webrtc/base/urlencode.h"
24 23
25 namespace rtc { 24 namespace rtc {
26 25
27 static const char EMPTY_STR[] = ""; 26 static const char EMPTY_STR[] = "";
28 27
29 // EXT_DELIM separates a file basename from extension 28 // EXT_DELIM separates a file basename from extension
30 const char EXT_DELIM = '.'; 29 const char EXT_DELIM = '.';
31 30
32 // FOLDER_DELIMS separate folder segments and the filename 31 // FOLDER_DELIMS separate folder segments and the filename
33 const char* const FOLDER_DELIMS = "/\\"; 32 const char* const FOLDER_DELIMS = "/\\";
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 pathname.append(basename_); 98 pathname.append(basename_);
100 pathname.append(extension_); 99 pathname.append(extension_);
101 if (pathname.empty()) { 100 if (pathname.empty()) {
102 // Instead of the empty pathname, return the current working directory. 101 // Instead of the empty pathname, return the current working directory.
103 pathname.push_back('.'); 102 pathname.push_back('.');
104 pathname.push_back(folder_delimiter_); 103 pathname.push_back(folder_delimiter_);
105 } 104 }
106 return pathname; 105 return pathname;
107 } 106 }
108 107
109 std::string Pathname::url() const {
110 std::string s = "file:///";
111 for (size_t i=0; i<folder_.length(); ++i) {
112 if (IsFolderDelimiter(folder_[i]))
113 s += '/';
114 else
115 s += folder_[i];
116 }
117 s += basename_;
118 s += extension_;
119 return UrlEncodeStringForOnlyUnsafeChars(s);
120 }
121
122 void Pathname::SetPathname(const std::string& pathname) { 108 void Pathname::SetPathname(const std::string& pathname) {
123 std::string::size_type pos = pathname.find_last_of(FOLDER_DELIMS); 109 std::string::size_type pos = pathname.find_last_of(FOLDER_DELIMS);
124 if (pos != std::string::npos) { 110 if (pos != std::string::npos) {
125 SetFolder(pathname.substr(0, pos + 1)); 111 SetFolder(pathname.substr(0, pos + 1));
126 SetFilename(pathname.substr(pos + 1)); 112 SetFilename(pathname.substr(pos + 1));
127 } else { 113 } else {
128 SetFolder(EMPTY_STR); 114 SetFolder(EMPTY_STR);
129 SetFilename(pathname); 115 SetFilename(pathname);
130 } 116 }
131 } 117 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // sanity checking 235 // sanity checking
250 return (isalpha(drive[0]) && 236 return (isalpha(drive[0]) &&
251 drive[1] == ':' && 237 drive[1] == ':' &&
252 drive[2] == '\\'); 238 drive[2] == '\\');
253 } 239 }
254 #endif 240 #endif
255 241
256 /////////////////////////////////////////////////////////////////////////////// 242 ///////////////////////////////////////////////////////////////////////////////
257 243
258 } // namespace rtc 244 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/pathutils.h ('k') | webrtc/base/pathutils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698