PageRenderTime 52ms CodeModel.GetById 42ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/google-toolbox-for-mac/Foundation/GTMNSFileManager+Path.h

http://macfuse.googlecode.com/
C++ Header | 75 lines | 11 code | 9 blank | 55 comment | 1 complexity | 42b8efc2242d4e0219c0d3be92df0311 MD5 | raw file
 1//
 2//  GTMNSFileManager+Path.h
 3//
 4//  Copyright 2006-2008 Google Inc.
 5//
 6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
 7//  use this file except in compliance with the License.  You may obtain a copy
 8//  of the License at
 9//
10//  http://www.apache.org/licenses/LICENSE-2.0
11//
12//  Unless required by applicable law or agreed to in writing, software
13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15//  License for the specific language governing permissions and limitations under
16//  the License.
17//
18
19#import <Foundation/Foundation.h>
20
21
22/// A few useful methods for dealing with paths.
23@interface NSFileManager (GMFileManagerPathAdditions)
24
25#if GTM_MACOS_SDK && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
26
27/// For the Unix-y at heart, this is "mkdir -p".  It tries to create
28/// the directory specified by |path|, and any intervening directories that
29/// are needed.  Each directory that is created is created with |attributes|
30/// (see other NSFileManager doco for the details on |attributes|).
31///
32/// If you are building for 10.5 or later, you should just use the new api:
33///  createDirectoryAtPath:withIntermediateDirectories:attributes:error:
34///
35/// Also if you need more control over the creation of paths and their
36/// attributes, look into using GTMPath.
37///
38/// Args:
39///   path - the path of the directory to create.
40///   attributes - these are defined in the "Constants" section of Apple's
41///                NSFileManager doco
42///
43/// Returns:
44///   YES if |path| exists or was able to be created successfully
45///   NO otherwise
46///
47- (BOOL)gtm_createFullPathToDirectory:(NSString *)path
48                           attributes:(NSDictionary *)attributes;
49
50#endif  // GTM_MACOS_SDK && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
51
52/// Return an the paths for all resources in |directoryPath| that have the
53/// |extension| file extension.
54///
55/// Args:
56///   extension - the file extension (excluding the leading ".") to match.
57///               If nil, all files are matched.
58///   directoryPath - the directory to look in.  NOTE: Subdirectories are NOT
59///                   traversed.
60///
61/// Returns:
62///   An NSArray of absolute file paths that have |extension|.  nil is returned
63///   if |directoryPath| doesn't exist or can't be opened, and returns an empty
64///   array if |directoryPath| is empty.  ".", "..", and resource forks are never returned.
65///
66- (NSArray *)gtm_filePathsWithExtension:(NSString *)extension
67                            inDirectory:(NSString *)directoryPath;
68
69/// Same as -filePathsWithExtension:inDirectory: except |extensions| is an
70/// NSArray of extensions to match.
71///
72- (NSArray *)gtm_filePathsWithExtensions:(NSArray *)extensions
73                             inDirectory:(NSString *)directoryPath;
74
75@end