OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 explicit RuntimeErrorWithErrno(const std::string& message) | 44 explicit RuntimeErrorWithErrno(const std::string& message) |
45 : std::runtime_error(message + " (" + strerror(errno) + ")") | 45 : std::runtime_error(message + " (" + strerror(errno) + ")") |
46 { | 46 { |
47 } | 47 } |
48 }; | 48 }; |
49 | 49 |
50 #ifdef WIN32 | 50 #ifdef WIN32 |
51 // Paths need to be converted from UTF-8 to UTF-16 on Windows. | 51 // Paths need to be converted from UTF-8 to UTF-16 on Windows. |
52 std::wstring NormalizePath(const std::string& path) | 52 std::wstring NormalizePath(const std::string& path) |
53 { | 53 { |
54 return Utils::ToUTF16String(path, path.length()); | 54 return Utils::ToUTF16String(path); |
55 } | 55 } |
56 | 56 |
57 #define rename _wrename | 57 #define rename _wrename |
58 #define remove _wremove | 58 #define remove _wremove |
59 #else | 59 #else |
60 // POSIX systems: assume that file system encoding is UTF-8 and just use the | 60 // POSIX systems: assume that file system encoding is UTF-8 and just use the |
61 // file paths as they are. | 61 // file paths as they are. |
62 #define NormalizePath(path) (path) | 62 #define NormalizePath(path) (path) |
63 #endif | 63 #endif |
64 } | 64 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 std::string DefaultFileSystem::Resolve(const std::string& path) const | 154 std::string DefaultFileSystem::Resolve(const std::string& path) const |
155 { | 155 { |
156 if (basePath == "") | 156 if (basePath == "") |
157 { | 157 { |
158 return path; | 158 return path; |
159 } | 159 } |
160 else | 160 else |
161 { | 161 { |
162 #ifdef _WIN32 | 162 #ifdef _WIN32 |
163 if (PathIsRelative(Utils::ToUTF16String(path, path.length()).c_str())) | 163 if (PathIsRelative(NormalizePath(path).c_str())) |
164 #else | 164 #else |
165 if (path.length() && *path.begin() != PATH_SEPARATOR) | 165 if (path.length() && *path.begin() != PATH_SEPARATOR) |
166 #endif | 166 #endif |
167 { | 167 { |
168 return basePath + PATH_SEPARATOR + path; | 168 return basePath + PATH_SEPARATOR + path; |
169 } | 169 } |
170 else | 170 else |
171 { | 171 { |
172 return path; | 172 return path; |
173 } | 173 } |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 void DefaultFileSystem::SetBasePath(const std::string& path) | 177 void DefaultFileSystem::SetBasePath(const std::string& path) |
178 { | 178 { |
179 basePath = path; | 179 basePath = path; |
180 | 180 |
181 if ((*basePath.rbegin() == PATH_SEPARATOR)) | 181 if ((*basePath.rbegin() == PATH_SEPARATOR)) |
182 { | 182 { |
183 basePath.resize(basePath.size() - 1); | 183 basePath.resize(basePath.size() - 1); |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
OLD | NEW |