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

Side by Side Diff: webrtc/test/testsupport/fileutils.cc

Issue 2744833002: Delete utf_util_win.h. (Closed)
Patch Set: Add rtc:: prefix to ToUtf16 and ToUtf8. Created 3 years, 9 months 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/system_wrappers/include/utf_util_win.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 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 #include "webrtc/test/testsupport/fileutils.h" 11 #include "webrtc/test/testsupport/fileutils.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 14
15 #ifdef WIN32 15 #ifdef WIN32
16 #include <direct.h> 16 #include <direct.h>
17 #include <tchar.h> 17 #include <tchar.h>
18 #include <windows.h> 18 #include <windows.h>
19 #include <algorithm> 19 #include <algorithm>
20 20
21 #include "Shlwapi.h" 21 #include "Shlwapi.h"
22 #include "WinDef.h" 22 #include "WinDef.h"
23 23
24 #include "webrtc/system_wrappers/include/utf_util_win.h" 24 #include "webrtc/base/win32.h"
25 #define GET_CURRENT_DIR _getcwd 25 #define GET_CURRENT_DIR _getcwd
26 #else 26 #else
27 #include <unistd.h> 27 #include <unistd.h>
28 28
29 #define GET_CURRENT_DIR getcwd 29 #define GET_CURRENT_DIR getcwd
30 #endif 30 #endif
31 31
32 #include <sys/stat.h> // To check for directory existence. 32 #include <sys/stat.h> // To check for directory existence.
33 #ifndef S_ISDIR // Not defined in stat.h on Windows. 33 #ifndef S_ISDIR // Not defined in stat.h on Windows.
34 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) 34 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 } 177 }
178 178
179 #endif // !WEBRTC_ANDROID 179 #endif // !WEBRTC_ANDROID
180 180
181 // Generate a temporary filename in a safe way. 181 // Generate a temporary filename in a safe way.
182 // Largely copied from talk/base/{unixfilesystem,win32filesystem}.cc. 182 // Largely copied from talk/base/{unixfilesystem,win32filesystem}.cc.
183 std::string TempFilename(const std::string &dir, const std::string &prefix) { 183 std::string TempFilename(const std::string &dir, const std::string &prefix) {
184 #ifdef WIN32 184 #ifdef WIN32
185 wchar_t filename[MAX_PATH]; 185 wchar_t filename[MAX_PATH];
186 if (::GetTempFileName(ToUtf16(dir).c_str(), 186 if (::GetTempFileName(rtc::ToUtf16(dir).c_str(),
187 ToUtf16(prefix).c_str(), 0, filename) != 0) 187 rtc::ToUtf16(prefix).c_str(), 0, filename) != 0)
188 return ToUtf8(filename); 188 return rtc::ToUtf8(filename);
189 assert(false); 189 assert(false);
190 return ""; 190 return "";
191 #else 191 #else
192 int len = dir.size() + prefix.size() + 2 + 6; 192 int len = dir.size() + prefix.size() + 2 + 6;
193 std::unique_ptr<char[]> tempname(new char[len]); 193 std::unique_ptr<char[]> tempname(new char[len]);
194 194
195 snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(), 195 snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(),
196 prefix.c_str()); 196 prefix.c_str());
197 int fd = ::mkstemp(tempname.get()); 197 int fd = ::mkstemp(tempname.get());
198 if (fd == -1) { 198 if (fd == -1) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 if (fseek(f, 0, SEEK_END) == 0) { 278 if (fseek(f, 0, SEEK_END) == 0) {
279 size = ftell(f); 279 size = ftell(f);
280 } 280 }
281 fclose(f); 281 fclose(f);
282 } 282 }
283 return size; 283 return size;
284 } 284 }
285 285
286 } // namespace test 286 } // namespace test
287 } // namespace webrtc 287 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/system_wrappers/include/utf_util_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698