2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include "NSFileManager+Extensions.h"
24 #include "NGFileFolderInfoDataSource.h"
25 #include <EOControl/EOGlobalID.h>
28 @interface NSFileManagerGlobalID : EOGlobalID < NSCopying >
35 // TODO: support -lastException
36 // TODO: add stuff like -dictionaryAtPath:, -arrayAtPath:, -propertyListAtPath:
38 @implementation NSFileManager(ExtendedFileManagerImp)
40 /* path modifications */
42 - (NSString *)standardizePath:(NSString *)_path {
43 if (![_path isAbsolutePath])
44 _path = [[self currentDirectoryPath] stringByAppendingPathComponent:_path];
46 return [_path stringByStandardizingPath];
48 - (NSString *)resolveSymlinksInPath:(NSString *)_path {
49 return [_path stringByResolvingSymlinksInPath];
51 - (NSString *)expandTildeInPath:(NSString *)_path {
52 return [_path stringByExpandingTildeInPath];
57 - (BOOL)supportsVersioningAtPath:(NSString *)_path {
60 - (BOOL)supportsLockingAtPath:(NSString *)_path {
63 - (BOOL)supportsFolderDataSourceAtPath:(NSString *)_path {
67 - (BOOL)supportsFeature:(NSString *)_featureURI atPath:(NSString *)_path {
68 if ([_featureURI isEqualToString:NGFileManagerFeature_DataSources])
76 - (BOOL)writeContents:(NSData *)_content atPath:(NSString *)_path {
77 return [_content writeToFile:_path atomically:YES];
82 - (EOGlobalID *)globalIDForPath:(NSString *)_path {
83 NSFileManagerGlobalID *gid;
85 _path = [self standardizePath:_path];
87 gid = [[NSFileManagerGlobalID alloc] init];
88 gid->path = [_path copy];
89 return [gid autorelease];
91 - (NSString *)pathForGlobalID:(EOGlobalID *)_gid {
92 NSFileManagerGlobalID *gid;
94 if (![_gid isKindOfClass:[NSFileManagerGlobalID class]])
95 /* not a gid we can handle ... */
98 gid = (NSFileManagerGlobalID *)_gid;
102 /* datasources (work on folders) */
104 - (EODataSource *)dataSourceAtPath:(NSString *)_path {
106 [[[NGFileFolderInfoDataSource alloc] initWithFolderPath:_path] autorelease];
109 - (EODataSource *)dataSource {
110 return [self dataSourceAtPath:[self currentDirectoryPath]];
115 - (BOOL)supportsTrashFolderAtPath:(NSString *)_path {
118 - (NSString *)trashFolderForPath:(NSString *)_path {
122 - (BOOL)trashFileAtPath:(NSString *)_path handler:(id)_handler {
123 // TODO: support trashfolder on MacOSX ?
127 @end /* NSFileManager(ExtendedFileManagerImp) */
129 @implementation NSFileManagerGlobalID
132 [self->path release];
138 - (id)copyWithZone:(NSZone *)_zone {
139 /* global IDs are immutable, so we can return an retained object ... */
140 return [self retain];
145 - (NSString *)description {
146 NSMutableString *ms = [NSMutableString stringWithCapacity:32];
148 [ms appendFormat:@"<0x%08X[%@]", self, NSStringFromClass([self class])];
149 [ms appendFormat:@" path=%@", self->path];
150 [ms appendString:@">"];
154 @end /* NSFileManagerGlobalID */