aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMNSFileManager+Path.h
diff options
context:
space:
mode:
authorGravatar thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-02-27 22:26:35 +0000
committerGravatar thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-02-27 22:26:35 +0000
commit1270f0c1ee5cf31faadc6ca41cf487cdd9e91508 (patch)
treee746e426a90bc27032b342e2861c59fcae6d6f12 /Foundation/GTMNSFileManager+Path.h
parentf38d4ee0e9157d2ac3c9a08fde37b9e19457fb0f (diff)
Added GTMNSFileManager+Path for two small helpers.
Diffstat (limited to 'Foundation/GTMNSFileManager+Path.h')
-rw-r--r--Foundation/GTMNSFileManager+Path.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/Foundation/GTMNSFileManager+Path.h b/Foundation/GTMNSFileManager+Path.h
new file mode 100644
index 0000000..330c45e
--- /dev/null
+++ b/Foundation/GTMNSFileManager+Path.h
@@ -0,0 +1,71 @@
+//
+// GTMNSFileManager+Path.h
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Foundation/Foundation.h>
+
+
+/// A few useful methods for dealing with paths.
+@interface NSFileManager (GMFileManagerPathAdditions)
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+
+/// For the Unix-y at heart, this is "mkdir -p". It tries to create
+/// the directory specified by |path|, and any intervening directories that
+/// are needed. Each directory that is created is created with |attributes|
+/// (see other NSFileManager doco for the details on |attributes|).
+///
+/// If you are building for 10.5 or later, you should just use the new api:
+/// createDirectoryAtPath:withIntermediateDirectories:attributes:error:
+///
+/// Args:
+/// path - the path of the directory to create.
+/// attributes - these are defined in the "Constants" section of Apple's
+/// NSFileManager doco
+///
+/// Returns:
+/// YES if |path| exists or was able to be created successfully
+/// NO otherwise
+///
+- (BOOL)gtm_createFullPathToDirectory:(NSString *)path
+ attributes:(NSDictionary *)attributes;
+
+#endif // MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+
+/// Return an the paths for all resources in |directoryPath| that have the
+/// |extension| file extension.
+///
+/// Args:
+/// extension - the file extension (excluding the leading ".") to match.
+/// If nil, all files are matched.
+/// directoryPath - the directory to look in. Subdirectories are not traversed.
+///
+/// Returns:
+/// An NSArray of absolute file paths that have |extension|. nil is returned
+/// if |directoryPath| doesn't exist or can't be opened, and returns an empty
+/// array if |directoryPath| is empty. ".", "..", and resource forks are never returned.
+///
+- (NSArray *)gtm_filePathsWithExtension:(NSString *)extension
+ inDirectory:(NSString *)directoryPath;
+
+/// Same as -filePathsWithExtension:inDirectory: except |extensions| is an
+/// NSArray of extensions to match.
+///
+- (NSArray *)gtm_filePathsWithExtensions:(NSArray *)extensions
+ inDirectory:(NSString *)directoryPath;
+
+@end