diff dwt/internal/cocoa/NSFileManager.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents f565d3a95c0a
children e1c48e37e0f5
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSFileManager.d	Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSFileManager.d	Mon Dec 01 17:07:00 2008 +0100
@@ -1,287 +1,59 @@
 /*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *     IBM Corporation - initial API and implementation
+ *    IBM Corporation - initial API and implementation
  *     
  * Port to the D programming language:
- *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *     Jacob Carlborg <doob@me.com>
  *******************************************************************************/
 module dwt.internal.cocoa.NSFileManager;
 
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSArray;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
 import dwt.internal.cocoa.NSData;
 import dwt.internal.cocoa.NSDictionary;
 import dwt.internal.cocoa.NSDirectoryEnumerator;
-import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSError;
+import dwt.internal.cocoa.NSObject;
 import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSObject;
 import dwt.internal.cocoa.OS;
 import objc = dwt.internal.objc.runtime;
 
-public class NSFileManager : NSObject
-{
-
-    public this ()
-    {
-        super();
-    }
-
-    public this (objc.id id)
-    {
-        super(id);
-    }
-
-    public NSDictionary attributesOfFileSystemForPath (NSString path, objc.id** error)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributesOfFileSystemForPath_1error_1, path !is null ? path.id_ : null, error);
-        return result !is null ? new NSDictionary(result) : null;
-    }
-
-    public NSDictionary attributesOfItemAtPath (NSString path, objc.id** error)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributesOfItemAtPath_1error_1, path !is null ? path.id_ : null, error);
-        return result !is null ? new NSDictionary(result) : null;
-    }
+public class NSFileManager : NSObject {
 
-    public bool changeCurrentDirectoryPath (NSString path)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_changeCurrentDirectoryPath_1, path !is null ? path.id_ : null) !is null;
-    }
-
-    public bool changeFileAttributes (NSDictionary attributes, NSString path)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_changeFileAttributes_1atPath_1, attributes !is null ? attributes.id_ : null,
-                path !is null ? path.id_ : null) !is null;
-    }
-
-    public NSArray componentsToDisplayForPath (NSString path)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_componentsToDisplayForPath_1, path !is null ? path.id_ : null);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSData contentsAtPath (NSString path)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_contentsAtPath_1, path !is null ? path.id_ : null);
-        return result !is null ? new NSData(result) : null;
-    }
-
-    public bool contentsEqualAtPath (NSString path1, NSString path2)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_contentsEqualAtPath_1andPath_1, path1 !is null ? path1.id_ : null, path2 !is null ? path2.id_ : null) !is null;
-    }
-
-    public NSArray contentsOfDirectoryAtPath (NSString path, objc.id** error)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_contentsOfDirectoryAtPath_1error_1, path !is null ? path.id_ : null, error);
-        return result !is null ? new NSArray(result) : null;
-    }
+public this() {
+    super();
+}
 
-    public bool copyItemAtPath (NSString srcPath, NSString dstPath, objc.id** error)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_copyItemAtPath_1toPath_1error_1, srcPath !is null ? srcPath.id_ : null,
-                dstPath !is null ? dstPath.id_ : null, error) !is null;
-    }
-
-    public bool copyPath (NSString src, NSString dest, id handler)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_copyPath_1toPath_1handler_1, src !is null ? src.id_ : null, dest !is null ? dest.id_ : null,
-                handler !is null ? handler.id_ : null) !is null;
-    }
-
-    public bool createDirectoryAtPath_attributes_ (NSString path, NSDictionary attributes)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_createDirectoryAtPath_1attributes_1, path !is null ? path.id_ : null,
-                attributes !is null ? attributes.id_ : null) !is null;
-    }
-
-    public bool createDirectoryAtPath_withIntermediateDirectories_attributes_error_ (NSString path, bool createIntermediates,
-            NSDictionary attributes, objc.id** error)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_createDirectoryAtPath_1withIntermediateDirectories_1attributes_1error_1,
-                path !is null ? path.id_ : null, createIntermediates, attributes !is null ? attributes.id_ : null, error) !is null;
-    }
-
-    public bool createFileAtPath (NSString path, NSData data, NSDictionary attr)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_createFileAtPath_1contents_1attributes_1, path !is null ? path.id_ : null,
-                data !is null ? data.id_ : null, attr !is null ? attr.id_ : null) !is null;
-    }
+public this(objc.id id) {
+    super(id);
+}
 
-    public bool createSymbolicLinkAtPath_pathContent_ (NSString path, NSString otherpath)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_createSymbolicLinkAtPath_1pathContent_1, path !is null ? path.id_ : null,
-                otherpath !is null ? otherpath.id_ : null) !is null;
-    }
-
-    public bool createSymbolicLinkAtPath_withDestinationPath_error_ (NSString path, NSString destPath, objc.id** error)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_createSymbolicLinkAtPath_1withDestinationPath_1error_1, path !is null ? path.id_ : null,
-                destPath !is null ? destPath.id_ : null, error) !is null;
-    }
-
-    public NSString currentDirectoryPath ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_currentDirectoryPath);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public static NSFileManager defaultManager ()
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFileManager, OS.sel_defaultManager);
-        return result !is null ? new NSFileManager(result) : null;
-    }
-
-    public id delegatee ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
-        return result !is null ? new id(result) : null;
-    }
-
-    public NSString destinationOfSymbolicLinkAtPath (NSString path, objc.id** error)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_destinationOfSymbolicLinkAtPath_1error_1, path !is null ? path.id_ : null, error);
-        return result !is null ? new NSString(result) : null;
-    }
+public this(cocoa.id id) {
+    super(id);
+}
 
-    public NSArray directoryContentsAtPath (NSString path)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_directoryContentsAtPath_1, path !is null ? path.id_ : null);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSString displayNameAtPath (NSString path)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_displayNameAtPath_1, path !is null ? path.id_ : null);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public NSDirectoryEnumerator enumeratorAtPath (NSString path)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_enumeratorAtPath_1, path !is null ? path.id_ : null);
-        return result !is null ? new NSDirectoryEnumerator(result) : null;
-    }
-
-    public NSDictionary fileAttributesAtPath (NSString path, bool yorn)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileAttributesAtPath_1traverseLink_1, path !is null ? path.id_ : null, yorn);
-        return result !is null ? new NSDictionary(result) : null;
-    }
-
-    public bool fileExistsAtPath_ (NSString path)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_fileExistsAtPath_1, path !is null ? path.id_ : null) !is null;
-    }
+public bool createFileAtPath(NSString path, NSData data, NSDictionary attr) {
+    return OS.objc_msgSend_bool(this.id, OS.sel_createFileAtPath_contents_attributes_, path !is null ? path.id : null, data !is null ? data.id : null, attr !is null ? attr.id : null);
+}
 
-    public bool fileExistsAtPath_isDirectory_ (NSString path, bool* isDirectory)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_fileExistsAtPath_1isDirectory_1, path !is null ? path.id_ : null, isDirectory) !is null;
-    }
-
-    public NSDictionary fileSystemAttributesAtPath (NSString path)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileSystemAttributesAtPath_1, path !is null ? path.id_ : null);
-        return result !is null ? new NSDictionary(result) : null;
-    }
-
-    public /*const*/char* fileSystemRepresentationWithPath (NSString path)
-    {
-        return cast(/*const*/char*) OS.objc_msgSend(this.id_, OS.sel_fileSystemRepresentationWithPath_1, path !is null ? path.id_ : null);
-    }
-
-    public bool isDeletableFileAtPath (NSString path)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_isDeletableFileAtPath_1, path !is null ? path.id_ : null) !is null;
-    }
-
-    public bool isExecutableFileAtPath (NSString path)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_isExecutableFileAtPath_1, path !is null ? path.id_ : null) !is null;
-    }
-
-    public bool isReadableFileAtPath (NSString path)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_isReadableFileAtPath_1, path !is null ? path.id_ : null) !is null;
-    }
-
-    public bool isWritableFileAtPath (NSString path)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_isWritableFileAtPath_1, path !is null ? path.id_ : null) !is null;
-    }
+public static NSFileManager defaultManager() {
+    objc.id result = OS.objc_msgSend(OS.class_NSFileManager, OS.sel_defaultManager);
+    return result !is null ? new NSFileManager(result) : null;
+}
 
-    public bool linkItemAtPath (NSString srcPath, NSString dstPath, objc.id** error)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_linkItemAtPath_1toPath_1error_1, srcPath !is null ? srcPath.id_ : null,
-                dstPath !is null ? dstPath.id_ : null, error) !is null;
-    }
-
-    public bool linkPath (NSString src, NSString dest, id handler)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_linkPath_1toPath_1handler_1, src !is null ? src.id_ : null, dest !is null ? dest.id_ : null,
-                handler !is null ? handler.id_ : null) !is null;
-    }
-
-    public bool moveItemAtPath (NSString srcPath, NSString dstPath, objc.id** error)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_moveItemAtPath_1toPath_1error_1, srcPath !is null ? srcPath.id_ : null,
-                dstPath !is null ? dstPath.id_ : null, error) !is null;
-    }
-
-    public bool movePath (NSString src, NSString dest, id handler)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_movePath_1toPath_1handler_1, src !is null ? src.id_ : null, dest !is null ? dest.id_ : null,
-                handler !is null ? handler.id_ : null) !is null;
-    }
-
-    public NSString pathContentOfSymbolicLinkAtPath (NSString path)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathContentOfSymbolicLinkAtPath_1, path !is null ? path.id_ : null);
-        return result !is null ? new NSString(result) : null;
-    }
+public NSDirectoryEnumerator enumeratorAtPath(NSString path) {
+    objc.id result = OS.objc_msgSend(this.id, OS.sel_enumeratorAtPath_, path !is null ? path.id : null);
+    return result !is null ? new NSDirectoryEnumerator(result) : null;
+}
 
-    public bool removeFileAtPath (NSString path, id handler)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_removeFileAtPath_1handler_1, path !is null ? path.id_ : null, handler !is null ? handler.id_ : null) !is null;
-    }
-
-    public bool removeItemAtPath (NSString path, objc.id** error)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_removeItemAtPath_1error_1, path !is null ? path.id_ : null, error) !is null;
-    }
-
-    public bool setAttributes (NSDictionary attributes, NSString path, objc.id** error)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_setAttributes_1ofItemAtPath_1error_1, attributes !is null ? attributes.id_ : null,
-                path !is null ? path.id_ : null, error) !is null;
-    }
-
-    public void setDelegate (id delegatee)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id_ : null);
-    }
-
-    public NSString stringWithFileSystemRepresentation (/*const*/char* str, NSUInteger len)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_stringWithFileSystemRepresentation_1length_1, str, len);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public NSArray subpathsAtPath (NSString path)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_subpathsAtPath_1, path !is null ? path.id_ : null);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSArray subpathsOfDirectoryAtPath (NSString path, objc.id** error)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_subpathsOfDirectoryAtPath_1error_1, path !is null ? path.id_ : null, error);
-        return result !is null ? new NSArray(result) : null;
-    }
+public bool removeItemAtPath(NSString path, ref NSError error) {
+    return OS.objc_msgSend_bool(this.id, OS.sel_removeItemAtPath_error_, path !is null ? path.id : null, error !is null ? &error.id : null);
+}
 
 }