1 | // |
---|
2 | // AIFileManagerAdditions.h |
---|
3 | // Adium |
---|
4 | // |
---|
5 | // Created by Adam Iser on Tue Dec 23 2003. |
---|
6 | // Copyright (c) 2003-2005 The Adium Team. All rights reserved. |
---|
7 | // |
---|
8 | |
---|
9 | #import <Foundation/Foundation.h> |
---|
10 | |
---|
11 | /* |
---|
12 | * @category NSFileManager(AIFileManagerAdditions) |
---|
13 | * @brief Additions to <tt>NSFileManager</tt> for trashing files and creating directories |
---|
14 | */ |
---|
15 | @interface NSFileManager (AIFileManagerAdditions) |
---|
16 | |
---|
17 | /* |
---|
18 | * @brief Determine the state of FileVault |
---|
19 | * |
---|
20 | * @result YES if FileVault is turned on; NO if it is not. |
---|
21 | */ |
---|
22 | - (BOOL)isFileVaultEnabled; |
---|
23 | |
---|
24 | /* |
---|
25 | * @brief Move a file or directory to the trash |
---|
26 | * |
---|
27 | * sourcePath does not need to be tildeExpanded; it will be expanded if necessary. |
---|
28 | * @param sourcePath Path to the file or directory to trash |
---|
29 | * @result YES if trashing was successful or the file already does not exist; NO if it failed |
---|
30 | */ |
---|
31 | - (BOOL)trashFileAtPath:(NSString *)sourcePath; |
---|
32 | |
---|
33 | /* |
---|
34 | * @brief Create all directories for a path |
---|
35 | * |
---|
36 | * Like <b>mkdir -p</b>, create the specified directory if it does not exist and create all intermediate directories as needed. |
---|
37 | * @param fullPath Path to be created |
---|
38 | * @result YES if one or more directories were created |
---|
39 | */ |
---|
40 | - (BOOL)createDirectoriesForPath:(NSString *)fullPath; |
---|
41 | |
---|
42 | /* |
---|
43 | * @brief Delete or trash all files in a directory starting with <b>prefix</b> |
---|
44 | * |
---|
45 | * The files must begin with characters matching <b>prefix</b> exactly; the comparison is case sensitive. |
---|
46 | * @param dirPath The directory in which to search |
---|
47 | * @param prefix The prefix for which to look, case sensitively |
---|
48 | * @param moveToTrash If YES, move the files to the trash. If NO, delete them permanently. |
---|
49 | */ |
---|
50 | - (void)removeFilesInDirectory:(NSString *)dirPath withPrefix:(NSString *)prefix movingToTrash:(BOOL)moveToTrash; |
---|
51 | |
---|
52 | #pragma mark - |
---|
53 | |
---|
54 | /* |
---|
55 | * @brief Returns the pathname passed in if it exists on disk (test -e). Doesn't care whether the path is a file or a directory. |
---|
56 | * @result The pathname passed in, or nil. |
---|
57 | */ |
---|
58 | - (NSString *)pathIfExists:(NSString *)path; |
---|
59 | |
---|
60 | /* |
---|
61 | * @brief Returns the pathname passed in if it exists on disk as a directory (test -d). |
---|
62 | * @result The pathname passed in, or nil. |
---|
63 | */ |
---|
64 | - (NSString *)pathIfDirectory:(NSString *)path; |
---|
65 | |
---|
66 | /* |
---|
67 | * @brief Returns the pathname passed in if it exists on disk as a non-directory (test ! -d). |
---|
68 | * @result The pathname passed in, or nil. |
---|
69 | */ |
---|
70 | - (NSString *)pathIfNotDirectory:(NSString *)path; |
---|
71 | |
---|
72 | - (NSString *)uniquePathForPath:(NSString *)inPath; |
---|
73 | |
---|
74 | - (NSString *)findFolderOfType:(OSType)type inDomain:(short)domain createFolder:(BOOL)createFolder; |
---|
75 | |
---|
76 | /* |
---|
77 | * @brief Returns the pathname of the user's application support directory |
---|
78 | * @result The pathname of the application support dir, or nil on error |
---|
79 | */ |
---|
80 | - (NSString *)userApplicationSupportFolder; |
---|
81 | |
---|
82 | /* |
---|
83 | * @brief Returns the actual path pointed to by an alias, or the path itself if it is not an alias |
---|
84 | * |
---|
85 | * It's safe to pass this any path. |
---|
86 | * |
---|
87 | * @result Resolved alias path or the original pathame passed in if it is not an alias |
---|
88 | */ |
---|
89 | - (NSString *)pathByResolvingAlias:(NSString *)path; |
---|
90 | |
---|
91 | @end |
---|