ProjectManager  0.2
FileManager.h
00001 /*
00002     FileManager.h
00003 
00004     Interface declaration of the FileManager class for the
00005     ProjectManager application.
00006 
00007     Copyright (C) 2005  Saso Kiselkov
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with this program; if not, write to the Free Software
00021     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 */
00023 
00024 #import <Foundation/NSObject.h>
00025 #import "../../ProjectModule.h"
00026 
00027 @class NSBrowser,
00028        NSMatrix,
00029        NSNotification,
00030        NSMutableArray,
00031        NSImage,
00032        NSError;
00033 
00034 @protocol NSDraggingInfo,
00035           FileManagerDelegate;
00036 
00037 /*
00038  * The pasteboard type used when dragging project files. The data
00039  * of the pasteboard is a property list of the form:
00040  * {
00041  *   Category = source-category;
00042  *   Project = project-file;     <- used to distinguish dragged files
00043  *                                  within projects and from one project
00044  *                                  to another project
00045  *   Contents = (
00046  *     <list-of-filenames>
00047  *   );
00048  * }
00049  */
00050 extern NSString * const ProjectFilesPboardType;
00051 
00066 typedef enum {
00067   FMFileTypePlain,
00068   FMFileTypeLink,
00069   FMFileTypeCategory,
00070   FMFileTypeVirtual
00071 } FMFileType;
00072 
00073 extern NSString * const ProjectFilesDidChangeNotification;
00074 
00075 extern NSString * const ProjectFilesErrorDomain;
00076 
00077 enum {
00078   ProjectFilesAlreadyExistError,
00079   ProjectFilesInvalidFileTypeError,
00080   ProjectFilesCreationError,
00081   ProjectFilesDeletionError,
00082   ProjectFilesCopyError,
00083   ProjectFilesMoveError,
00084   ProjectFilesGenericFileImportError
00085 };
00086 
00087 @class ProjectBrowser,
00088        ProjectImageView,
00089        NSTextField,
00090        NSImageView;
00091 
00092 @interface FileManager : NSObject <ProjectModule>
00093 {
00094   id view;
00095   id bogusWindow;
00096 
00097   ProjectBrowser * browser;
00098   ProjectImageView * fileIcon;
00099   NSTextField * fileNameField;
00100   NSTextField * filePathField;
00101   NSTextField * fileSizeField;
00102   NSTextField * fileTypeField;
00103   NSTextField * lastModifiedField;
00104 
00105   // the root category contents array
00106   NSMutableArray * files;
00107   id <FileManagerDelegate> delegate;    // weak reference
00108   ProjectDocument * document;
00109 }
00110 
00111 - delegate;
00112 
00113 - (void) openFile: (id)sender;
00114 
00115 - (void)      browser: (NSBrowser *) sender
00116   createRowsForColumn: (int) column
00117              inMatrix: (NSMatrix *) matrix;
00118 - (NSString *) browser: (NSBrowser *)sender titleOfColumn: (int)column;
00119 
00120 - (void) selectFile: sender;
00121 - (void) changeName: sender;
00122 
00123 - (void) selectAndEditNameAtPath: (NSString *) aPath;
00124 
00125 - (NSArray *) selectedFiles;
00126 - (NSString *) containingCategory;
00127 
00128 - (BOOL) performDragOperation: (id <NSDraggingInfo>) sender;
00129 
00130 - (BOOL) openPath: (NSString *) aPath;
00131 
00132 /* project file/category management */
00133 - (BOOL) fileExistsAtPath: (NSString *) aPath;
00134 - (NSArray *) filesAtPath: (NSString *) category;
00135 - (FMFileType) typeOfFileAtPath: (NSString *) aPath;
00136 - (NSString *) targetOfLinkAtPath: (NSString *) aPath;
00137 - (unsigned long long) measureDiskUsageAtPath: (NSString *) aPath;
00138 - (NSString *) pathToFileAtPhysicalPath: (NSString *) diskLocation;
00139 
00140 - (NSArray *) filesAtPath: (NSString *) aCategory
00141                    ofType: (FMFileType) aFileType
00142                 recursive: (BOOL) recursive;
00143 
00144 - (BOOL) importFile: (NSString *) filePath
00145              toPath: (NSString *) category
00146                link: (BOOL) linkFlag
00147               error: (NSError **) error;
00148 - (BOOL) importFile: (NSString *) filePath
00149            renameTo: (NSString *) aNewName
00150              toPath: (NSString *) category
00151                link: (BOOL) linkFlag
00152               error: (NSError **) error;
00153 - (BOOL) createCategory: (NSString *) categoryName
00154                  atPath: (NSString *) category
00155                   error: (NSError **) error;
00156 - (BOOL) createCategoryAndIntermediateCategories: (NSString *) category
00157                                            error: (NSError **) error;
00158 - (BOOL) createVirtualFileNamed: (NSString *) filename
00159                          atPath: (NSString *) category
00160                           error: (NSError **) error;
00161 
00166 - (BOOL) removePath: (NSString *) aPath
00167              delete: (BOOL) deleleFlag
00168               error: (NSError **) error;
00169 
00170 - (BOOL) copyPath: (NSString *) aPath
00171            toPath: (NSString *) newPath
00172             error: (NSError **) error;
00173 
00174 - (BOOL) movePath: (NSString *) aPath
00175            toPath: (NSString *) newPath
00176             error: (NSError **) error;
00177 
00178 - (BOOL) linkPath: (NSString *) aPath
00179          fromPath: (NSString *) newPath
00180             error: (NSError **) error;
00181 
00182 - (NSImage *) iconForPath: (NSString *) aPath;
00183 
00184 // menu actions
00185 - (void) importFiles: sender;
00186 - (void) newEmptyFile: sender;
00187 - (void) newFileFromTemplate: sender;
00188 - (void) newCategory: sender;
00189 - (void) deleteFiles: sender;
00190 
00191 // notifications
00192 - (void) filesChanged: (NSNotification *) notif;
00193 - (void) projectNameChanged: (NSNotification *) notif;
00194 
00195 @end