OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/mac/launchd.h" | 5 #include "chrome/common/mac/launchd.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 #include <launch.h> | 8 #include <launch.h> |
9 | 9 |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 NSString *launch_dir_name = (type == Launchd::Daemon) ? @"LaunchDaemons" | 37 NSString *launch_dir_name = (type == Launchd::Daemon) ? @"LaunchDaemons" |
38 : @"LaunchAgents"; | 38 : @"LaunchAgents"; |
39 NSString* launch_dir = | 39 NSString* launch_dir = |
40 [library_path stringByAppendingPathComponent:launch_dir_name]; | 40 [library_path stringByAppendingPathComponent:launch_dir_name]; |
41 | 41 |
42 NSError* err; | 42 NSError* err; |
43 if (![[NSFileManager defaultManager] createDirectoryAtPath:launch_dir | 43 if (![[NSFileManager defaultManager] createDirectoryAtPath:launch_dir |
44 withIntermediateDirectories:YES | 44 withIntermediateDirectories:YES |
45 attributes:nil | 45 attributes:nil |
46 error:&err]) { | 46 error:&err]) { |
47 LOG(ERROR) << "GetPlistURL " << base::mac::NSToCFCast(err); | 47 DLOG(ERROR) << "GetPlistURL " << base::mac::NSToCFCast(err); |
48 return nil; | 48 return nil; |
49 } | 49 } |
50 | 50 |
51 NSString* plist_file_path = | 51 NSString* plist_file_path = |
52 [launch_dir stringByAppendingPathComponent:base::mac::CFToNSCast(name)]; | 52 [launch_dir stringByAppendingPathComponent:base::mac::CFToNSCast(name)]; |
53 plist_file_path = [plist_file_path stringByAppendingPathExtension:@"plist"]; | 53 plist_file_path = [plist_file_path stringByAppendingPathExtension:@"plist"]; |
54 return [NSURL fileURLWithPath:plist_file_path isDirectory:NO]; | 54 return [NSURL fileURLWithPath:plist_file_path isDirectory:NO]; |
55 } | 55 } |
56 | 56 |
57 } // namespace | 57 } // namespace |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 return [base::mac::CFToNSCast(dict) writeToURL:ns_url atomically:YES]; | 154 return [base::mac::CFToNSCast(dict) writeToURL:ns_url atomically:YES]; |
155 } | 155 } |
156 | 156 |
157 bool Launchd::DeletePlist(Domain domain, Type type, CFStringRef name) { | 157 bool Launchd::DeletePlist(Domain domain, Type type, CFStringRef name) { |
158 base::mac::ScopedNSAutoreleasePool pool; | 158 base::mac::ScopedNSAutoreleasePool pool; |
159 NSURL* ns_url = GetPlistURL(domain, type, name); | 159 NSURL* ns_url = GetPlistURL(domain, type, name); |
160 NSError* err = nil; | 160 NSError* err = nil; |
161 if (![[NSFileManager defaultManager] removeItemAtPath:[ns_url path] | 161 if (![[NSFileManager defaultManager] removeItemAtPath:[ns_url path] |
162 error:&err]) { | 162 error:&err]) { |
163 if ([err code] != NSFileNoSuchFileError) { | 163 if ([err code] != NSFileNoSuchFileError) { |
164 LOG(ERROR) << "DeletePlist: " << base::mac::NSToCFCast(err); | 164 DLOG(ERROR) << "DeletePlist: " << base::mac::NSToCFCast(err); |
165 } | 165 } |
166 return false; | 166 return false; |
167 } | 167 } |
168 return true; | 168 return true; |
169 } | 169 } |
OLD | NEW |