1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "updaterfileutils_osx.h"
8 #include <Cocoa/Cocoa.h>
10 bool IsRecursivelyWritable(const char* aPath) {
11 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
13 NSString* rootPath = [NSString stringWithUTF8String:aPath];
14 NSFileManager* fileManager = [NSFileManager defaultManager];
16 NSArray* subPaths = [fileManager subpathsOfDirectoryAtPath:rootPath
18 NSMutableArray* paths =
19 [NSMutableArray arrayWithCapacity:[subPaths count] + 1];
20 [paths addObject:@""];
21 [paths addObjectsFromArray:subPaths];
28 for (NSString* currPath in paths) {
29 NSString* child = [rootPath stringByAppendingPathComponent:currPath];
31 NSDictionary* attributes = [fileManager attributesOfItemAtPath:child
38 // Don't check for writability of files pointed to by symlinks, as they may
39 // not be descendants of the root path.
40 if ([attributes fileType] != NSFileTypeSymbolicLink &&
41 [fileManager isWritableFileAtPath:child] == NO) {