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

Side by Side Diff: webrtc/base/applefilesystem.mm

Issue 2877023002: Move webrtc/{base => rtc_base} (Closed)
Patch Set: update presubmit.py and DEPS include rules Created 3 years, 5 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/base/OWNERS ('k') | webrtc/base/array_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 // This file only exists because various iOS and macOS system APIs are only
12 // available from Objective-C. See unixfilesystem.cc for the only use
13 // (enforced by a lack of a header file).
14
15 #import <Foundation/NSPathUtilities.h>
16 #import <Foundation/NSProcessInfo.h>
17 #include <string.h>
18
19 #include "webrtc/base/checks.h"
20 #include "webrtc/base/pathutils.h"
21
22 // Return a new[]'d |char*| copy of the UTF8 representation of |s|.
23 // Caller owns the returned memory and must use delete[] on it.
24 static char* copyString(NSString* s) {
25 const char* utf8 = [s UTF8String];
26 size_t len = strlen(utf8) + 1;
27 char* copy = new char[len];
28 // This uses a new[] + strcpy (instead of strdup) because the
29 // receiver expects to be able to delete[] the returned pointer
30 // (instead of free()ing it).
31 strcpy(copy, utf8);
32 return copy;
33 }
34
35 // Return a (leaked) copy of a directory name suitable for application data.
36 char* AppleDataDirectory() {
37 NSArray* paths = NSSearchPathForDirectoriesInDomains(
38 NSApplicationSupportDirectory, NSUserDomainMask, YES);
39 RTC_DCHECK([paths count] == 1);
40 return copyString([paths objectAtIndex:0]);
41 }
42
43 // Return a (leaked) copy of a directory name suitable for use as a $TEMP.
44 char* AppleTempDirectory() {
45 return copyString(NSTemporaryDirectory());
46 }
47
48 // Return the binary's path.
49 void AppleAppName(rtc::Pathname* path) {
50 NSProcessInfo* pInfo = [NSProcessInfo processInfo];
51 NSString* argv0 = [[pInfo arguments] objectAtIndex:0];
52 path->SetPathname([argv0 UTF8String]);
53 }
OLDNEW
« no previous file with comments | « webrtc/base/OWNERS ('k') | webrtc/base/array_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698