view dwt/internal/cocoa/NSFileHandle.d @ 1:8b48be5454ce

The internal cocoa classes compile now
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Tue, 19 Aug 2008 17:35:17 +0200
parents 380af2bdd8e5
children f565d3a95c0a
line wrap: on
line source

/*******************************************************************************
 * Copyright (c) 2007 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
 *     
 * Port to the D Programming language:
 *     Jacob Carlborg <jacob.carlborg@gmail.com>
 *******************************************************************************/
module dwt.internal.cocoa.NSFileHandle;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSData;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSFileHandle : NSObject
{

    public this ()
    {
        super();
    }

    public this (objc.id id)
    {
        super(id);
    }

    public void acceptConnectionInBackgroundAndNotify ()
    {
        OS.objc_msgSend(this.id_, OS.sel_acceptConnectionInBackgroundAndNotify);
    }

    public void acceptConnectionInBackgroundAndNotifyForModes (NSArray modes)
    {
        OS.objc_msgSend(this.id_, OS.sel_acceptConnectionInBackgroundAndNotifyForModes_1, modes !is null ? modes.id_ : null);
    }

    public NSData availableData ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableData);
        return result !is null ? new NSData(result) : null;
    }

    public void closeFile ()
    {
        OS.objc_msgSend(this.id_, OS.sel_closeFile);
    }

    public int fileDescriptor ()
    {
        return cast(int) OS.objc_msgSend(this.id_, OS.sel_fileDescriptor);
    }

    public static id fileHandleForReadingAtPath (NSString path)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleForReadingAtPath_1, path !is null ? path.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public static id fileHandleForUpdatingAtPath (NSString path)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleForUpdatingAtPath_1, path !is null ? path.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public static id fileHandleForWritingAtPath (NSString path)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleForWritingAtPath_1, path !is null ? path.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public static id fileHandleWithNullDevice ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleWithNullDevice);
        return result !is null ? new id(result) : null;
    }

    public static id fileHandleWithStandardError ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleWithStandardError);
        return result !is null ? new id(result) : null;
    }

    public static id fileHandleWithStandardInput ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleWithStandardInput);
        return result !is null ? new id(result) : null;
    }

    public static id fileHandleWithStandardOutput ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleWithStandardOutput);
        return result !is null ? new id(result) : null;
    }

    public id initWithFileDescriptor_ (int fd)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithFileDescriptor_1, fd);
        return result !is null ? new id(result) : null;
    }

    public id initWithFileDescriptor_closeOnDealloc_ (int fd, bool closeopt)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithFileDescriptor_1closeOnDealloc_1, fd, closeopt);
        return result !is null ? new id(result) : null;
    }

    public long offsetInFile ()
    {
        return cast(long) OS.objc_msgSend(this.id_, OS.sel_offsetInFile);
    }

    public NSData readDataOfLength (NSUInteger length)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_readDataOfLength_1, length);
        return result !is null ? new NSData(result) : null;
    }

    public NSData readDataToEndOfFile ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_readDataToEndOfFile);
        return result !is null ? new NSData(result) : null;
    }

    public void readInBackgroundAndNotify ()
    {
        OS.objc_msgSend(this.id_, OS.sel_readInBackgroundAndNotify);
    }

    public void readInBackgroundAndNotifyForModes (NSArray modes)
    {
        OS.objc_msgSend(this.id_, OS.sel_readInBackgroundAndNotifyForModes_1, modes !is null ? modes.id_ : null);
    }

    public void readToEndOfFileInBackgroundAndNotify ()
    {
        OS.objc_msgSend(this.id_, OS.sel_readToEndOfFileInBackgroundAndNotify);
    }

    public void readToEndOfFileInBackgroundAndNotifyForModes (NSArray modes)
    {
        OS.objc_msgSend(this.id_, OS.sel_readToEndOfFileInBackgroundAndNotifyForModes_1, modes !is null ? modes.id_ : null);
    }

    public long seekToEndOfFile ()
    {
        return cast(long) OS.objc_msgSend(this.id_, OS.sel_seekToEndOfFile);
    }

    public void seekToFileOffset (long offset)
    {
        OS.objc_msgSend(this.id_, OS.sel_seekToFileOffset_1, offset);
    }

    public void synchronizeFile ()
    {
        OS.objc_msgSend(this.id_, OS.sel_synchronizeFile);
    }

    public void truncateFileAtOffset (long offset)
    {
        OS.objc_msgSend(this.id_, OS.sel_truncateFileAtOffset_1, offset);
    }

    public void waitForDataInBackgroundAndNotify ()
    {
        OS.objc_msgSend(this.id_, OS.sel_waitForDataInBackgroundAndNotify);
    }

    public void waitForDataInBackgroundAndNotifyForModes (NSArray modes)
    {
        OS.objc_msgSend(this.id_, OS.sel_waitForDataInBackgroundAndNotifyForModes_1, modes !is null ? modes.id_ : null);
    }

    public void writeData (NSData data)
    {
        OS.objc_msgSend(this.id_, OS.sel_writeData_1, data !is null ? data.id_ : null);
    }

}