diff dstep/foundation/NSFileManager.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 7ff919f595d5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/foundation/NSFileManager.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,428 @@
+/**
+ * Copyright: Copyright (c) 2009 Jacob Carlborg.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 3, 2009 
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ */
+module dstep.foundation.NSFileManager;
+
+import dstep.corefoundation.CFBase;
+import dstep.foundation.NSArray;
+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.NSObject;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+
+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;
+
+static this ()
+{
+	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);
+}
+
+class NSFileManager : NSObject
+{
+	mixin ObjcWrap;
+
+	static NSFileManager defaultManager ()
+	{
+		return invokeObjcSelfClass!(NSFileManager, "defaultManager"return result is this.objcObject ? this : (result !is null ? new NSFileManager(result) : null);	}
+
+	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);
+	}
+
+	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 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);
+	}
+
+	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, 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;
+
+	NSDictionary fileAttributes ()
+	{
+		return invokeObjcSelf!(NSDictionary, "fileAttributes");
+	}
+
+	NSDictionary directoryAttributes ()
+	{
+		return invokeObjcSelf!(NSDictionary, "directoryAttributes");
+	}
+
+	void skipDescendents ()
+	{
+		return invokeObjcSelf!(void, "skipDescendents");
+	}
+}
+
+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);
+}
+
+template TNSCopyLinkMoveHandler ()
+{
+	bool fileManager (NSFileManager fm, NSDictionary errorInfo);
+	void fileManager (NSFileManager fm, NSString path);
+}
+
+template TNSFileAttributes ()
+{
+	ulong fileSize ()
+	{
+		return invokeObjcSelf!(ulong, "fileSize");
+	}
+
+	NSDate fileModificationDate ()
+	{
+		return invokeObjcSelf!(NSDate, "fileModificationDate");
+	}
+
+	NSString fileType ()
+	{
+		return invokeObjcSelf!(NSString, "fileType");
+	}
+
+	NSUInteger filePosixPermissions ()
+	{
+		return invokeObjcSelf!(NSUInteger, "filePosixPermissions");
+	}
+
+	NSString fileOwnerAccountName ()
+	{
+		return invokeObjcSelf!(NSString, "fileOwnerAccountName");
+	}
+
+	NSString fileGroupOwnerAccountName ()
+	{
+		return invokeObjcSelf!(NSString, "fileGroupOwnerAccountName");
+	}
+
+	NSInteger fileSystemNumber ()
+	{
+		return invokeObjcSelf!(NSInteger, "fileSystemNumber");
+	}
+
+	NSUInteger fileSystemFileNumber ()
+	{
+		return invokeObjcSelf!(NSUInteger, "fileSystemFileNumber");
+	}
+
+	bool fileExtensionHidden ()
+	{
+		return invokeObjcSelf!(bool, "fileExtensionHidden");
+	}
+
+	uint fileHFSCreatorCode ()
+	{
+		return invokeObjcSelf!(uint, "fileHFSCreatorCode");
+	}
+
+	uint fileHFSTypeCode ()
+	{
+		return invokeObjcSelf!(uint, "fileHFSTypeCode");
+	}
+
+	bool fileIsImmutable ()
+	{
+		return invokeObjcSelf!(bool, "fileIsImmutable");
+	}
+
+	bool fileIsAppendOnly ()
+	{
+		return invokeObjcSelf!(bool, "fileIsAppendOnly");
+	}
+
+	NSDate fileCreationDate ()
+	{
+		return invokeObjcSelf!(NSDate, "fileCreationDate");
+	}
+
+	NSNumber fileOwnerAccountID ()
+	{
+		return invokeObjcSelf!(NSNumber, "fileOwnerAccountID");
+	}
+
+	NSNumber fileGroupOwnerAccountID ()
+	{
+		return invokeObjcSelf!(NSNumber, "fileGroupOwnerAccountID");
+	}
+}
+