Mercurial > projects > dstep
diff dstep/foundation/NSFileManager.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 7ff919f595d5 |
children | b9de51448c6b |
line wrap: on
line diff
--- a/dstep/foundation/NSFileManager.d Mon Aug 03 15:31:48 2009 +0200 +++ b/dstep/foundation/NSFileManager.d Sun Jan 03 22:06:11 2010 +0100 @@ -11,341 +11,361 @@ import dstep.foundation.NSData; import dstep.foundation.NSDate; import dstep.foundation.NSDictionary; -import dstep.foundation.NSDirectoryEnumerator; import dstep.foundation.NSEnumerator; import dstep.foundation.NSError; -import dstep.foundation.NSNumber; +import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSObject; +import dstep.foundation.NSString; +import dstep.foundation.NSValue; import dstep.objc.bridge.Bridge; -import dstep.objc.objc : id; +import dstep.objc.objc; import bindings = dstep.foundation.NSFileManager_bindings; -const NSString NSFileType; -const NSString NSFileTypeDirectory; -const NSString NSFileTypeRegular; -const NSString NSFileTypeSymbolicLink; -const NSString NSFileTypeSocket; -const NSString NSFileTypeCharacterSpecial; -const NSString NSFileTypeBlockSpecial; -const NSString NSFileTypeUnknown; -const NSString NSFileSize; -const NSString NSFileModificationDate; -const NSString NSFileReferenceCount; -const NSString NSFileDeviceIdentifier; -const NSString NSFileOwnerAccountName; -const NSString NSFileGroupOwnerAccountName; -const NSString NSFilePosixPermissions; -const NSString NSFileSystemNumber; -const NSString NSFileSystemFileNumber; -const NSString NSFileExtensionHidden; -const NSString NSFileHFSCreatorCode; -const NSString NSFileHFSTypeCode; -const NSString NSFileImmutable; -const NSString NSFileAppendOnly; -const NSString NSFileCreationDate; -const NSString NSFileOwnerAccountID; -const NSString NSFileGroupOwnerAccountID; -const NSString NSFileBusy; -const NSString NSFileSystemSize; -const NSString NSFileSystemFreeSize; -const NSString NSFileSystemNodes; -const NSString NSFileSystemFreeNodes; +private +{ + NSString NSFileType_; + NSString NSFileTypeDirectory_; + NSString NSFileTypeRegular_; + NSString NSFileTypeSymbolicLink_; + NSString NSFileTypeSocket_; + NSString NSFileTypeCharacterSpecial_; + NSString NSFileTypeBlockSpecial_; + NSString NSFileTypeUnknown_; + NSString NSFileSize_; + NSString NSFileModificationDate_; + NSString NSFileReferenceCount_; + NSString NSFileDeviceIdentifier_; + NSString NSFileOwnerAccountName_; + NSString NSFileGroupOwnerAccountName_; + NSString NSFilePosixPermissions_; + NSString NSFileSystemNumber_; + NSString NSFileSystemFileNumber_; + NSString NSFileExtensionHidden_; + NSString NSFileHFSCreatorCode_; + NSString NSFileHFSTypeCode_; + NSString NSFileImmutable_; + NSString NSFileAppendOnly_; + NSString NSFileCreationDate_; + NSString NSFileOwnerAccountID_; + NSString NSFileGroupOwnerAccountID_; + NSString NSFileBusy_; + NSString NSFileSystemSize_; + NSString NSFileSystemFreeSize_; + NSString NSFileSystemNodes_; + NSString NSFileSystemFreeNodes_; +} + +NSString NSFileType () +{ + if (NSFileType_) + return NSFileType_; + + return NSFileType_ = new NSString(bindings.NSFileType); +} + +NSString NSFileTypeDirectory () +{ + if (NSFileTypeDirectory_) + return NSFileTypeDirectory_; + + return NSFileTypeDirectory_ = new NSString(bindings.NSFileTypeDirectory); +} + +NSString NSFileTypeRegular () +{ + if (NSFileTypeRegular_) + return NSFileTypeRegular_; + + return NSFileTypeRegular_ = new NSString(bindings.NSFileTypeRegular); +} + +NSString NSFileTypeSymbolicLink () +{ + if (NSFileTypeSymbolicLink_) + return NSFileTypeSymbolicLink_; + + return NSFileTypeSymbolicLink_ = new NSString(bindings.NSFileTypeSymbolicLink); +} + +NSString NSFileTypeSocket () +{ + if (NSFileTypeSocket_) + return NSFileTypeSocket_; + + return NSFileTypeSocket_ = new NSString(bindings.NSFileTypeSocket); +} + +NSString NSFileTypeCharacterSpecial () +{ + if (NSFileTypeCharacterSpecial_) + return NSFileTypeCharacterSpecial_; + + return NSFileTypeCharacterSpecial_ = new NSString(bindings.NSFileTypeCharacterSpecial); +} -static this () +NSString NSFileTypeBlockSpecial () +{ + if (NSFileTypeBlockSpecial_) + return NSFileTypeBlockSpecial_; + + return NSFileTypeBlockSpecial_ = new NSString(bindings.NSFileTypeBlockSpecial); +} + +NSString NSFileTypeUnknown () +{ + if (NSFileTypeUnknown_) + return NSFileTypeUnknown_; + + return NSFileTypeUnknown_ = new NSString(bindings.NSFileTypeUnknown); +} + +NSString NSFileSize () +{ + if (NSFileSize_) + return NSFileSize_; + + return NSFileSize_ = new NSString(bindings.NSFileSize); +} + +NSString NSFileModificationDate () +{ + if (NSFileModificationDate_) + return NSFileModificationDate_; + + return NSFileModificationDate_ = new NSString(bindings.NSFileModificationDate); +} + +NSString NSFileReferenceCount () +{ + if (NSFileReferenceCount_) + return NSFileReferenceCount_; + + return NSFileReferenceCount_ = new NSString(bindings.NSFileReferenceCount); +} + +NSString NSFileDeviceIdentifier () { - NSFileType = new NSString(bindings.NSFileType); - NSFileTypeDirectory = new NSString(bindings.NSFileTypeDirectory); - NSFileTypeRegular = new NSString(bindings.NSFileTypeRegular); - NSFileTypeSymbolicLink = new NSString(bindings.NSFileTypeSymbolicLink); - NSFileTypeSocket = new NSString(bindings.NSFileTypeSocket); - NSFileTypeCharacterSpecial = new NSString(bindings.NSFileTypeCharacterSpecial); - NSFileTypeBlockSpecial = new NSString(bindings.NSFileTypeBlockSpecial); - NSFileTypeUnknown = new NSString(bindings.NSFileTypeUnknown); - NSFileSize = new NSString(bindings.NSFileSize); - NSFileModificationDate = new NSString(bindings.NSFileModificationDate); - NSFileReferenceCount = new NSString(bindings.NSFileReferenceCount); - NSFileDeviceIdentifier = new NSString(bindings.NSFileDeviceIdentifier); - NSFileOwnerAccountName = new NSString(bindings.NSFileOwnerAccountName); - NSFileGroupOwnerAccountName = new NSString(bindings.NSFileGroupOwnerAccountName); - NSFilePosixPermissions = new NSString(bindings.NSFilePosixPermissions); - NSFileSystemNumber = new NSString(bindings.NSFileSystemNumber); - NSFileSystemFileNumber = new NSString(bindings.NSFileSystemFileNumber); - NSFileExtensionHidden = new NSString(bindings.NSFileExtensionHidden); - NSFileHFSCreatorCode = new NSString(bindings.NSFileHFSCreatorCode); - NSFileHFSTypeCode = new NSString(bindings.NSFileHFSTypeCode); - NSFileImmutable = new NSString(bindings.NSFileImmutable); - NSFileAppendOnly = new NSString(bindings.NSFileAppendOnly); - NSFileCreationDate = new NSString(bindings.NSFileCreationDate); - NSFileOwnerAccountID = new NSString(bindings.NSFileOwnerAccountID); - NSFileGroupOwnerAccountID = new NSString(bindings.NSFileGroupOwnerAccountID); - NSFileBusy = new NSString(bindings.NSFileBusy); - NSFileSystemSize = new NSString(bindings.NSFileSystemSize); - NSFileSystemFreeSize = new NSString(bindings.NSFileSystemFreeSize); - NSFileSystemNodes = new NSString(bindings.NSFileSystemNodes); - NSFileSystemFreeNodes = new NSString(bindings.NSFileSystemFreeNodes); + if (NSFileDeviceIdentifier_) + return NSFileDeviceIdentifier_; + + return NSFileDeviceIdentifier_ = new NSString(bindings.NSFileDeviceIdentifier); +} + +NSString NSFileOwnerAccountName () +{ + if (NSFileOwnerAccountName_) + return NSFileOwnerAccountName_; + + return NSFileOwnerAccountName_ = new NSString(bindings.NSFileOwnerAccountName); +} + +NSString NSFileGroupOwnerAccountName () +{ + if (NSFileGroupOwnerAccountName_) + return NSFileGroupOwnerAccountName_; + + return NSFileGroupOwnerAccountName_ = new NSString(bindings.NSFileGroupOwnerAccountName); +} + +NSString NSFilePosixPermissions () +{ + if (NSFilePosixPermissions_) + return NSFilePosixPermissions_; + + return NSFilePosixPermissions_ = new NSString(bindings.NSFilePosixPermissions); +} + +NSString NSFileSystemNumber () +{ + if (NSFileSystemNumber_) + return NSFileSystemNumber_; + + return NSFileSystemNumber_ = new NSString(bindings.NSFileSystemNumber); +} + +NSString NSFileSystemFileNumber () +{ + if (NSFileSystemFileNumber_) + return NSFileSystemFileNumber_; + + return NSFileSystemFileNumber_ = new NSString(bindings.NSFileSystemFileNumber); } -class NSFileManager : NSObject +NSString NSFileExtensionHidden () { - mixin ObjcWrap; - - static NSFileManager defaultManager () - { - return invokeObjcSelfClass!(NSFileManager, "defaultManager"); - } - - void setDelegate (Object delegate_) - { - return invokeObjcSelf!(void, "setDelegate:", Object)(delegate_); - } - - Object delegate_ () - { - return invokeObjcSelf!(Object, "delegate"); - } - - bool setAttributes (NSDictionary attributes, NSString path, NSError** error) - { - return invokeObjcSelf!(bool, "setAttributes:ofItemAtPath:error:", NSDictionary, NSString, NSError**)(attributes, path, error); - } + if (NSFileExtensionHidden_) + return NSFileExtensionHidden_; + + return NSFileExtensionHidden_ = new NSString(bindings.NSFileExtensionHidden); +} - bool createDirectoryAtPath (NSString path, bool createIntermediates, NSDictionary attributes, NSError** error) - { - return invokeObjcSelf!(bool, "createDirectoryAtPath:withIntermediateDirectories:attributes:error:", NSString, bool, NSDictionary, NSError**)(path, createIntermediates, attributes, error); - } - - NSArray contentsOfDirectoryAtPath (NSString path, NSError** error) - { - return invokeObjcSelf!(NSArray, "contentsOfDirectoryAtPath:error:", NSString, NSError**)(path, error); - } - - NSArray subpathsOfDirectoryAtPath (NSString path, NSError** error) - { - return invokeObjcSelf!(NSArray, "subpathsOfDirectoryAtPath:error:", NSString, NSError**)(path, error); - } - - NSDictionary attributesOfItemAtPath (NSString path, NSError** error) - { - return invokeObjcSelf!(NSDictionary, "attributesOfItemAtPath:error:", NSString, NSError**)(path, error); - } - - NSDictionary attributesOfFileSystemForPath (NSString path, NSError** error) - { - return invokeObjcSelf!(NSDictionary, "attributesOfFileSystemForPath:error:", NSString, NSError**)(path, error); - } - - bool createSymbolicLinkAtPath (NSString path, NSString destPath, NSError** error) - { - return invokeObjcSelf!(bool, "createSymbolicLinkAtPath:withDestinationPath:error:", NSString, NSString, NSError**)(path, destPath, error); - } +NSString NSFileHFSCreatorCode () +{ + if (NSFileHFSCreatorCode_) + return NSFileHFSCreatorCode_; + + return NSFileHFSCreatorCode_ = new NSString(bindings.NSFileHFSCreatorCode); +} - NSString destinationOfSymbolicLinkAtPath (NSString path, NSError** error) - { - return invokeObjcSelf!(NSString, "destinationOfSymbolicLinkAtPath:error:", NSString, NSError**)(path, error); - } - - bool copyItemAtPath (NSString srcPath, NSString dstPath, NSError** error) - { - return invokeObjcSelf!(bool, "copyItemAtPath:toPath:error:", NSString, NSString, NSError**)(srcPath, dstPath, error); - } - - bool moveItemAtPath (NSString srcPath, NSString dstPath, NSError** error) - { - return invokeObjcSelf!(bool, "moveItemAtPath:toPath:error:", NSString, NSString, NSError**)(srcPath, dstPath, error); - } - - bool linkItemAtPath (NSString srcPath, NSString dstPath, NSError** error) - { - return invokeObjcSelf!(bool, "linkItemAtPath:toPath:error:", NSString, NSString, NSError**)(srcPath, dstPath, error); - } - - bool removeItemAtPath (NSString path, NSError** error) - { - return invokeObjcSelf!(bool, "removeItemAtPath:error:", NSString, NSError**)(path, error); - } +NSString NSFileHFSTypeCode () +{ + if (NSFileHFSTypeCode_) + return NSFileHFSTypeCode_; + + return NSFileHFSTypeCode_ = new NSString(bindings.NSFileHFSTypeCode); +} - NSDictionary fileAttributesAtPath (NSString path, bool yorn) - { - return invokeObjcSelf!(NSDictionary, "fileAttributesAtPath:traverseLink:", NSString, bool)(path, yorn); - } - - bool changeFileAttributes (NSDictionary attributes, NSString path) - { - return invokeObjcSelf!(bool, "changeFileAttributes:atPath:", NSDictionary, NSString)(attributes, path); - } - - NSArray directoryContentsAtPath (NSString path) - { - return invokeObjcSelf!(NSArray, "directoryContentsAtPath:", NSString)(path); - } - - NSDictionary fileSystemAttributesAtPath (NSString path) - { - return invokeObjcSelf!(NSDictionary, "fileSystemAttributesAtPath:", NSString)(path); - } - - NSString pathContentOfSymbolicLinkAtPath (NSString path) - { - return invokeObjcSelf!(NSString, "pathContentOfSymbolicLinkAtPath:", NSString)(path); - } - - bool createSymbolicLinkAtPath (NSString path, NSString otherpath) - { - return invokeObjcSelf!(bool, "createSymbolicLinkAtPath:pathContent:", NSString, NSString)(path, otherpath); - } +NSString NSFileImmutable () +{ + if (NSFileImmutable_) + return NSFileImmutable_; + + return NSFileImmutable_ = new NSString(bindings.NSFileImmutable); +} - bool createDirectoryAtPath (NSString path, NSDictionary attributes) - { - return invokeObjcSelf!(bool, "createDirectoryAtPath:attributes:", NSString, NSDictionary)(path, attributes); - } - - bool linkPath (NSString src, NSString dest, Object handler) - { - return invokeObjcSelf!(bool, "linkPath:toPath:handler:", NSString, NSString, Object)(src, dest, handler); - } - - bool copyPath (NSString src, NSString dest, Object handler) - { - return invokeObjcSelf!(bool, "copyPath:toPath:handler:", NSString, NSString, Object)(src, dest, handler); - } - - bool movePath (NSString src, NSString dest, Object handler) - { - return invokeObjcSelf!(bool, "movePath:toPath:handler:", NSString, NSString, Object)(src, dest, handler); - } - - bool removeFileAtPath (NSString path, Object handler) - { - return invokeObjcSelf!(bool, "removeFileAtPath:handler:", NSString, Object)(path, handler); - } +NSString NSFileAppendOnly () +{ + if (NSFileAppendOnly_) + return NSFileAppendOnly_; + + return NSFileAppendOnly_ = new NSString(bindings.NSFileAppendOnly); +} - NSString currentDirectoryPath () - { - return invokeObjcSelf!(NSString, "currentDirectoryPath"); - } - - bool changeCurrentDirectoryPath (NSString path) - { - return invokeObjcSelf!(bool, "changeCurrentDirectoryPath:", NSString)(path); - } - - bool fileExistsAtPath (NSString path) - { - return invokeObjcSelf!(bool, "fileExistsAtPath:", NSString)(path); - } - - bool fileExistsAtPath (NSString path, bool* isDirectory) - { - return invokeObjcSelf!(bool, "fileExistsAtPath:isDirectory:", NSString, bool*)(path, isDirectory); - } - - bool isReadableFileAtPath (NSString path) - { - return invokeObjcSelf!(bool, "isReadableFileAtPath:", NSString)(path); - } - - bool isWritableFileAtPath (NSString path) - { - return invokeObjcSelf!(bool, "isWritableFileAtPath:", NSString)(path); - } +NSString NSFileCreationDate () +{ + if (NSFileCreationDate_) + return NSFileCreationDate_; + + return NSFileCreationDate_ = new NSString(bindings.NSFileCreationDate); +} - bool isExecutableFileAtPath (NSString path) - { - return invokeObjcSelf!(bool, "isExecutableFileAtPath:", NSString)(path); - } - - bool isDeletableFileAtPath (NSString path) - { - return invokeObjcSelf!(bool, "isDeletableFileAtPath:", NSString)(path); - } - - bool contentsEqualAtPath (NSString path1, NSString path2) - { - return invokeObjcSelf!(bool, "contentsEqualAtPath:andPath:", NSString, NSString)(path1, path2); - } - - NSString displayNameAtPath (NSString path) - { - return invokeObjcSelf!(NSString, "displayNameAtPath:", NSString)(path); - } - - NSArray componentsToDisplayForPath (NSString path) - { - return invokeObjcSelf!(NSArray, "componentsToDisplayForPath:", NSString)(path); - } +NSString NSFileOwnerAccountID () +{ + if (NSFileOwnerAccountID_) + return NSFileOwnerAccountID_; + + return NSFileOwnerAccountID_ = new NSString(bindings.NSFileOwnerAccountID); +} - NSDirectoryEnumerator enumeratorAtPath (NSString path) - { - return invokeObjcSelf!(NSDirectoryEnumerator, "enumeratorAtPath:", NSString)(path); - } - - NSArray subpathsAtPath (NSString path) - { - return invokeObjcSelf!(NSArray, "subpathsAtPath:", NSString)(path); - } - - NSData contentsAtPath (NSString path) - { - return invokeObjcSelf!(NSData, "contentsAtPath:", NSString)(path); - } +NSString NSFileGroupOwnerAccountID () +{ + if (NSFileGroupOwnerAccountID_) + return NSFileGroupOwnerAccountID_; + + return NSFileGroupOwnerAccountID_ = new NSString(bindings.NSFileGroupOwnerAccountID); +} - bool createFileAtPath (NSString path, NSData data, NSDictionary attr) - { - return invokeObjcSelf!(bool, "createFileAtPath:contents:attributes:", NSString, NSData, NSDictionary)(path, data, attr); - } +NSString NSFileBusy () +{ + if (NSFileBusy_) + return NSFileBusy_; + + return NSFileBusy_ = new NSString(bindings.NSFileBusy); +} - char* fileSystemRepresentationWithPath (NSString path) - { - return invokeObjcSelf!(char*, "fileSystemRepresentationWithPath:", NSString)(path); - } - - NSString stringWithFileSystemRepresentation (char* str, NSUInteger len) - { - return invokeObjcSelf!(NSString, "stringWithFileSystemRepresentation:length:", char*, NSUInteger)(str, len); - } +NSString NSFileSystemSize () +{ + if (NSFileSystemSize_) + return NSFileSystemSize_; + + return NSFileSystemSize_ = new NSString(bindings.NSFileSystemSize); } -class NSDirectoryEnumerator : NSEnumerator +NSString NSFileSystemFreeSize () { - mixin ObjcWrap; - - NSDictionary fileAttributes () - { - return invokeObjcSelf!(NSDictionary, "fileAttributes"); - } + if (NSFileSystemFreeSize_) + return NSFileSystemFreeSize_; + + return NSFileSystemFreeSize_ = new NSString(bindings.NSFileSystemFreeSize); +} - NSDictionary directoryAttributes () - { - return invokeObjcSelf!(NSDictionary, "directoryAttributes"); - } +NSString NSFileSystemNodes () +{ + if (NSFileSystemNodes_) + return NSFileSystemNodes_; + + return NSFileSystemNodes_ = new NSString(bindings.NSFileSystemNodes); +} - void skipDescendents () - { - return invokeObjcSelf!(void, "skipDescendents"); - } +NSString NSFileSystemFreeNodes () +{ + if (NSFileSystemFreeNodes_) + return NSFileSystemFreeNodes_; + + return NSFileSystemFreeNodes_ = new NSString(bindings.NSFileSystemFreeNodes); } -template TNSFileManagerFileOperationAdditions () -{ - bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath); - bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath); - bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath); - bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath); - bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath); - bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath); - bool fileManager (NSFileManager fileManager, NSString path); - bool fileManager (NSFileManager fileManager, NSError error, NSString path); -} +const TNSFileManagerFileOperationAdditions = ` -template TNSCopyLinkMoveHandler () -{ - bool fileManager (NSFileManager fm, NSDictionary errorInfo); - void fileManager (NSFileManager fm, NSString path); -} + bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath) + { + return invokeObjcSelf!(bool, "fileManager:shouldCopyItemAtPath:toPath:dstPath:", NSFileManager, NSString, NSString); + } + + bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath) + { + return invokeObjcSelf!(bool, "fileManager:shouldProceedAfterError:copyingItemAtPath:toPath:", NSFileManager, NSError, NSString, NSString)(fileManager, error, srcPath, dstPath); + } + + bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath) + { + return invokeObjcSelf!(bool, "fileManager:shouldMoveItemAtPath:toPath:", NSFileManager, NSString, NSString)(fileManager, srcPath, dstPath); + } + + bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath) + { + return invokeObjcSelf!(bool, "fileManager:shouldProceedAfterError:movingItemAtPath:toPath:", NSFileManager, NSError, NSString, NSString)(fileManager, error, srcPath, dstPath); + } + + bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath) + { + return invokeObjcSelf!(bool, "fileManager:shouldLinkItemAtPath:toPath:", NSFileManager, NSString, NSString)(fileManager, srcPath, dstPath); + } + + bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath) + { + return invokeObjcSelf!(bool, "fileManager:shouldProceedAfterError:linkingItemAtPath:toPath", NSFileManager, NSError, NSString, NSString)(fileManager, error, srcPath, dstPath); + } + + bool fileManager (NSFileManager fileManager, NSString path) + { + return invokeObjcSelf!(bool, "fileManager:shouldRemoveItemAtPath:", NSFileManager, NSString)(fileManager, path); + } + + bool fileManager (NSFileManager fileManager, NSError error, NSString path) + { + return invokeObjcSelf!(bool, "fileManager:shouldProceedAfterError:removingItemAtPath:", NSFileManager, NSError, NSString)(fileManager, error, path); + } + + //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldCopyItemAtPath:toPath:dstPath:", NSFileManager, NSString, NSString); + //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldProceedAfterError:copyingItemAtPath:toPath:", NSFileManager, NSError, NSString, NSString); + //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldMoveItemAtPath:toPath:", NSFileManager, NSString, NSString); + //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldProceedAfterError:movingItemAtPath:toPath:", NSFileManager, NSError, NSString, NSString); + //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldLinkItemAtPath:toPath:", NSFileManager, NSString, NSString); + //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldProceedAfterError:linkingItemAtPath:toPath", NSFileManager, NSError, NSString, NSString); + //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldRemoveItemAtPath:", NSFileManager, NSString); + //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldProceedAfterError:removingItemAtPath:", NSFileManager, NSError, NSString); +`; -template TNSFileAttributes () -{ +const TNSCopyLinkMoveHandler = ` + + bool fileManager (NSFileManager fm, NSDictionary errorInfo) + { + return invokeObjcSelf!(bool, "fileManager:shouldProceedAfterError:", NSFileManager, NSDictionary)(fm, errorInfo); + } + + void fileManager (NSFileManager fm, NSString path) + { + return invokeObjcSelf!(void, "fileManager:willProcessPath:", NSFileManager, NSString)(fm, path); + } + + //mixin ObjcBindMethod!(fileManager, "fileManager:shouldProceedAfterError:"); + //mixin ObjcBindMethod!(fileManager, "fileManager:willProcessPath:"); +`; + +const TNSFileAttributes = ` + ulong fileSize () { return invokeObjcSelf!(ulong, "fileSize"); @@ -425,5 +445,384 @@ { return invokeObjcSelf!(NSNumber, "fileGroupOwnerAccountID"); } +`; + +class NSFileManager : NSObject +{ + mixin (ObjcWrap); + + this () + { + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); + } + + static NSFileManager defaultManager () + { + return invokeObjcSuperClass!(NSFileManager, "defaultManager"); + } + + void setDelegate (Object delegate_) + { + return invokeObjcSelf!(void, "setDelegate:", Object)(delegate_); + } + + Object delegate_ () + { + return invokeObjcSelf!(Object, "delegate"); + } + + bool setAttributes (NSDictionary attributes, NSString path, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + bool result = invokeObjcSelf!(bool, "setAttributes:ofItemAtPath:error:", NSDictionary, NSString, id*)(attributes, path, &err); + + if (err) + error = new NSError(err); + + return result; + } + + bool createDirectoryAtPath (NSString path, bool createIntermediates, NSDictionary attributes, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + bool result = invokeObjcSelf!(bool, "createDirectoryAtPath:withIntermediateDirectories:attributes:error:", NSString, bool, NSDictionary, id*)(path, createIntermediates, attributes, &err); + + if (err) + error = new NSError(err); + + return result; + } + + NSArray contentsOfDirectoryAtPath (NSString path, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + NSArray result = invokeObjcSelf!(NSArray, "contentsOfDirectoryAtPath:error:", NSString, id*)(path, &err); + + if (err) + error = new NSError(err); + + return result; + } + + NSArray subpathsOfDirectoryAtPath (NSString path, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + NSArray result = invokeObjcSelf!(NSArray, "subpathsOfDirectoryAtPath:error:", NSString, id*)(path, &err); + + if (err) + error = new NSError(err); + + return result; + } + + NSDictionary attributesOfItemAtPath (NSString path, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + NSDictionary result = invokeObjcSelf!(NSDictionary, "attributesOfItemAtPath:error:", NSString, id*)(path, &err); + + if (err) + error = new NSError(err); + + return result; + } + + NSDictionary attributesOfFileSystemForPath (NSString path, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + NSDictionary result = invokeObjcSelf!(NSDictionary, "attributesOfFileSystemForPath:error:", NSString, id*)(path, &err); + + if (err) + error = new NSError(err); + + return result; + } + + bool createSymbolicLinkAtPath (NSString path, NSString destPath, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + bool result = invokeObjcSelf!(bool, "createSymbolicLinkAtPath:withDestinationPath:error:", NSString, NSString, id*)(path, destPath, &err); + + if (err) + error = new NSError(err); + + return result; + } + + NSString destinationOfSymbolicLinkAtPath (NSString path, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + NSString result = invokeObjcSelf!(NSString, "destinationOfSymbolicLinkAtPath:error:", NSString, id*)(path, &err); + + if (err) + error = new NSError(err); + + return result; + } + + bool copyItemAtPath (NSString srcPath, NSString dstPath, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + bool result = invokeObjcSelf!(bool, "copyItemAtPath:toPath:error:", NSString, NSString, id*)(srcPath, dstPath, &err); + + if (err) + error = new NSError(err); + + return result; + } + + bool moveItemAtPath (NSString srcPath, NSString dstPath, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + bool result = invokeObjcSelf!(bool, "moveItemAtPath:toPath:error:", NSString, NSString, id*)(srcPath, dstPath, &err); + + if (err) + error = new NSError(err); + + return result; + } + + bool linkItemAtPath (NSString srcPath, NSString dstPath, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + bool result = invokeObjcSelf!(bool, "linkItemAtPath:toPath:error:", NSString, NSString, id*)(srcPath, dstPath, &err); + + if (err) + error = new NSError(err); + + return result; + } + + bool removeItemAtPath (NSString path, ref NSError error) + { + id err; + + if (error) + err = new objc_object; + + bool result = invokeObjcSelf!(bool, "removeItemAtPath:error:", NSString, id*)(path, &err); + + if (err) + error = new NSError(err); + + return result; + } + + NSDictionary fileAttributesAtPath (NSString path, bool yorn) + { + return invokeObjcSelf!(NSDictionary, "fileAttributesAtPath:traverseLink:", NSString, bool)(path, yorn); + } + + bool changeFileAttributes (NSDictionary attributes, NSString path) + { + return invokeObjcSelf!(bool, "changeFileAttributes:atPath:", NSDictionary, NSString)(attributes, path); + } + + NSArray directoryContentsAtPath (NSString path) + { + return invokeObjcSelf!(NSArray, "directoryContentsAtPath:", NSString)(path); + } + + NSDictionary fileSystemAttributesAtPath (NSString path) + { + return invokeObjcSelf!(NSDictionary, "fileSystemAttributesAtPath:", NSString)(path); + } + + NSString pathContentOfSymbolicLinkAtPath (NSString path) + { + return invokeObjcSelf!(NSString, "pathContentOfSymbolicLinkAtPath:", NSString)(path); + } + + bool createSymbolicLinkAtPath (NSString path, NSString otherpath) + { + return invokeObjcSelf!(bool, "createSymbolicLinkAtPath:pathContent:", NSString, NSString)(path, otherpath); + } + + bool createDirectoryAtPath (NSString path, NSDictionary attributes) + { + return invokeObjcSelf!(bool, "createDirectoryAtPath:attributes:", NSString, NSDictionary)(path, attributes); + } + + bool linkPath (NSString src, NSString dest, Object handler) + { + return invokeObjcSelf!(bool, "linkPath:toPath:handler:", NSString, NSString, Object)(src, dest, handler); + } + + bool copyPath (NSString src, NSString dest, Object handler) + { + return invokeObjcSelf!(bool, "copyPath:toPath:handler:", NSString, NSString, Object)(src, dest, handler); + } + + bool movePath (NSString src, NSString dest, Object handler) + { + return invokeObjcSelf!(bool, "movePath:toPath:handler:", NSString, NSString, Object)(src, dest, handler); + } + + bool removeFileAtPath (NSString path, Object handler) + { + return invokeObjcSelf!(bool, "removeFileAtPath:handler:", NSString, Object)(path, handler); + } + + NSString currentDirectoryPath () + { + return invokeObjcSelf!(NSString, "currentDirectoryPath"); + } + + bool changeCurrentDirectoryPath (NSString path) + { + return invokeObjcSelf!(bool, "changeCurrentDirectoryPath:", NSString)(path); + } + + bool fileExistsAtPath (NSString path) + { + return invokeObjcSelf!(bool, "fileExistsAtPath:", NSString)(path); + } + + bool fileExistsAtPath (NSString path, out bool isDirectory) + { + return invokeObjcSelf!(bool, "fileExistsAtPath:isDirectory:", NSString, bool*)(path, &isDirectory); + } + + bool isReadableFileAtPath (NSString path) + { + return invokeObjcSelf!(bool, "isReadableFileAtPath:", NSString)(path); + } + + bool isWritableFileAtPath (NSString path) + { + return invokeObjcSelf!(bool, "isWritableFileAtPath:", NSString)(path); + } + + bool isExecutableFileAtPath (NSString path) + { + return invokeObjcSelf!(bool, "isExecutableFileAtPath:", NSString)(path); + } + + bool isDeletableFileAtPath (NSString path) + { + return invokeObjcSelf!(bool, "isDeletableFileAtPath:", NSString)(path); + } + + bool contentsEqualAtPath (NSString path1, NSString path2) + { + return invokeObjcSelf!(bool, "contentsEqualAtPath:andPath:", NSString, NSString)(path1, path2); + } + + NSString displayNameAtPath (NSString path) + { + return invokeObjcSelf!(NSString, "displayNameAtPath:", NSString)(path); + } + + NSArray componentsToDisplayForPath (NSString path) + { + return invokeObjcSelf!(NSArray, "componentsToDisplayForPath:", NSString)(path); + } + + NSDirectoryEnumerator enumeratorAtPath (NSString path) + { + return invokeObjcSelf!(NSDirectoryEnumerator, "enumeratorAtPath:", NSString)(path); + } + + NSArray subpathsAtPath (NSString path) + { + return invokeObjcSelf!(NSArray, "subpathsAtPath:", NSString)(path); + } + + NSData contentsAtPath (NSString path) + { + return invokeObjcSelf!(NSData, "contentsAtPath:", NSString)(path); + } + + bool createFileAtPath (NSString path, NSData data, NSDictionary attr) + { + return invokeObjcSelf!(bool, "createFileAtPath:contents:attributes:", NSString, NSData, NSDictionary)(path, data, attr); + } + + char* fileSystemRepresentationWithPath (NSString path) + { + return invokeObjcSelf!(char*, "fileSystemRepresentationWithPath:", NSString)(path); + } + + NSString stringWithFileSystemRepresentation (char* str, NSUInteger len) + { + return invokeObjcSelf!(NSString, "stringWithFileSystemRepresentation:length:", char*, NSUInteger)(str, len); + } } +class NSDirectoryEnumerator : NSEnumerator +{ + mixin (ObjcWrap); + + this () + { + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); + } + + NSDictionary fileAttributes () + { + return invokeObjcSelf!(NSDictionary, "fileAttributes"); + } + + NSDictionary directoryAttributes () + { + return invokeObjcSelf!(NSDictionary, "directoryAttributes"); + } + + void skipDescendents () + { + return invokeObjcSelf!(void, "skipDescendents"); + } +} \ No newline at end of file