Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/DefaultFileSystem.cpp

Issue 10518027: Don`t use stat() on Windows, use a Unicode-safe Windows function instead (Closed)
Patch Set: Addressed review comments Created May 17, 2013, 10:44 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/AdblockPlus/FileSystem.h ('k') | no next file » | 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 * 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 90 }
91 91
92 FileSystem::StatResult DefaultFileSystem::Stat(const std::string& path) const 92 FileSystem::StatResult DefaultFileSystem::Stat(const std::string& path) const
93 { 93 {
94 FileSystem::StatResult result; 94 FileSystem::StatResult result;
95 #ifdef WIN32 95 #ifdef WIN32
96 WIN32_FILE_ATTRIBUTE_DATA data; 96 WIN32_FILE_ATTRIBUTE_DATA data;
97 if (!GetFileAttributesExW(NormalizePath(path).c_str(), GetFileExInfoStandard, &data)) 97 if (!GetFileAttributesExW(NormalizePath(path).c_str(), GetFileExInfoStandard, &data))
98 { 98 {
99 DWORD err = GetLastError(); 99 DWORD err = GetLastError();
100 if (err == ERROR_FILE_NOT_FOUND || ERROR_PATH_NOT_FOUND || ERROR_INVALID_DRI VE) 100 if (err == ERROR_FILE_NOT_FOUND ||
101 err == ERROR_PATH_NOT_FOUND ||
102 err == ERROR_INVALID_DRIVE)
103 {
101 return result; 104 return result;
105 }
102 throw RuntimeErrorWithErrno("Unable to stat " + path); 106 throw RuntimeErrorWithErrno("Unable to stat " + path);
103 } 107 }
104 108
105 result.exists = true; 109 result.exists = true;
106 if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 110 if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
107 { 111 {
108 result.isFile = false; 112 result.isFile = false;
109 result.isDirectory = true; 113 result.isDirectory = true;
110 } 114 }
111 else 115 else
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 void DefaultFileSystem::SetBasePath(const std::string& path) 181 void DefaultFileSystem::SetBasePath(const std::string& path)
178 { 182 {
179 basePath = path; 183 basePath = path;
180 184
181 if (*basePath.rbegin() == PATH_SEPARATOR) 185 if (*basePath.rbegin() == PATH_SEPARATOR)
182 { 186 {
183 basePath.resize(basePath.size() - 1); 187 basePath.resize(basePath.size() - 1);
184 } 188 }
185 } 189 }
186 190
OLDNEW
« no previous file with comments | « include/AdblockPlus/FileSystem.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld