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

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

Issue 1937693002: Replace scoped_ptr with unique_ptr everywhere (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@unique5
Patch Set: Created 4 years, 7 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/test/test_suite.h ('k') | webrtc/tools/agc/activity_metric.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 (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 "webrtc/system_wrappers/include/utf_util_win.h" 21 #include "webrtc/system_wrappers/include/utf_util_win.h"
22 #define GET_CURRENT_DIR _getcwd 22 #define GET_CURRENT_DIR _getcwd
23 #else 23 #else
24 #include <unistd.h> 24 #include <unistd.h>
25 25
26 #include "webrtc/base/scoped_ptr.h"
27 #define GET_CURRENT_DIR getcwd 26 #define GET_CURRENT_DIR getcwd
28 #endif 27 #endif
29 28
30 #include <sys/stat.h> // To check for directory existence. 29 #include <sys/stat.h> // To check for directory existence.
31 #ifndef S_ISDIR // Not defined in stat.h on Windows. 30 #ifndef S_ISDIR // Not defined in stat.h on Windows.
32 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) 31 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
33 #endif 32 #endif
34 33
35 #include <stdio.h> 34 #include <stdio.h>
36 #include <stdlib.h> 35 #include <stdlib.h>
37 #include <string.h> 36 #include <string.h>
38 37
38 #include <memory>
39
39 #include "webrtc/typedefs.h" // For architecture defines 40 #include "webrtc/typedefs.h" // For architecture defines
40 41
41 namespace webrtc { 42 namespace webrtc {
42 namespace test { 43 namespace test {
43 44
44 #if defined(WEBRTC_IOS) 45 #if defined(WEBRTC_IOS)
45 // Defined in iosfileutils.mm. No header file to discourage use elsewhere. 46 // Defined in iosfileutils.mm. No header file to discourage use elsewhere.
46 std::string IOSOutputPath(); 47 std::string IOSOutputPath();
47 std::string IOSResourcePath(std::string name, std::string extension); 48 std::string IOSResourcePath(std::string name, std::string extension);
48 #endif 49 #endif
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 std::string TempFilename(const std::string &dir, const std::string &prefix) { 177 std::string TempFilename(const std::string &dir, const std::string &prefix) {
177 #ifdef WIN32 178 #ifdef WIN32
178 wchar_t filename[MAX_PATH]; 179 wchar_t filename[MAX_PATH];
179 if (::GetTempFileName(ToUtf16(dir).c_str(), 180 if (::GetTempFileName(ToUtf16(dir).c_str(),
180 ToUtf16(prefix).c_str(), 0, filename) != 0) 181 ToUtf16(prefix).c_str(), 0, filename) != 0)
181 return ToUtf8(filename); 182 return ToUtf8(filename);
182 assert(false); 183 assert(false);
183 return ""; 184 return "";
184 #else 185 #else
185 int len = dir.size() + prefix.size() + 2 + 6; 186 int len = dir.size() + prefix.size() + 2 + 6;
186 rtc::scoped_ptr<char[]> tempname(new char[len]); 187 std::unique_ptr<char[]> tempname(new char[len]);
187 188
188 snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(), 189 snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(),
189 prefix.c_str()); 190 prefix.c_str());
190 int fd = ::mkstemp(tempname.get()); 191 int fd = ::mkstemp(tempname.get());
191 if (fd == -1) { 192 if (fd == -1) {
192 assert(false); 193 assert(false);
193 return ""; 194 return "";
194 } else { 195 } else {
195 ::close(fd); 196 ::close(fd);
196 } 197 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 if (fseek(f, 0, SEEK_END) == 0) { 271 if (fseek(f, 0, SEEK_END) == 0) {
271 size = ftell(f); 272 size = ftell(f);
272 } 273 }
273 fclose(f); 274 fclose(f);
274 } 275 }
275 return size; 276 return size;
276 } 277 }
277 278
278 } // namespace test 279 } // namespace test
279 } // namespace webrtc 280 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/test_suite.h ('k') | webrtc/tools/agc/activity_metric.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698