/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3.25
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

namespace clucene.net {

using System;
using System.Runtime.InteropServices;

public class Directory : IDisposable {
  private HandleRef swigCPtr;
  protected bool swigCMemOwn;

  internal Directory(IntPtr cPtr, bool cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(Directory obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  ~Directory() {
    Dispose();
  }

  public virtual void Dispose() {
    if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
      swigCMemOwn = false;
      libCLcsharpPINVOKE.delete_Directory(swigCPtr);
    }
    swigCPtr = new HandleRef(null, IntPtr.Zero);
    GC.SuppressFinalize(this);
  }

  public virtual string[] list() { return new _CL_p_p_charArray(libCLcsharpPINVOKE.Directory_list(swigCPtr),true).toArray(); }

  public virtual bool fileExists(string name) {
    bool ret = libCLcsharpPINVOKE.Directory_fileExists(swigCPtr, name);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual long fileModified(string name) {
    long ret = libCLcsharpPINVOKE.Directory_fileModified(swigCPtr, name);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual long fileLength(string name) {
    long ret = libCLcsharpPINVOKE.Directory_fileLength(swigCPtr, name);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual InputStream openFile(string name) {
    IntPtr cPtr = libCLcsharpPINVOKE.Directory_openFile(swigCPtr, name);
    InputStream ret = (cPtr == IntPtr.Zero) ? null : new InputStream(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual void touchFile(string name) {
    libCLcsharpPINVOKE.Directory_touchFile(swigCPtr, name);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public virtual void deleteFile(string name, bool throwError) {
    libCLcsharpPINVOKE.Directory_deleteFile__SWIG_0(swigCPtr, name, throwError);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public virtual void deleteFile(string name) {
    libCLcsharpPINVOKE.Directory_deleteFile__SWIG_1(swigCPtr, name);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public virtual void renameFile(string from, string to) {
    libCLcsharpPINVOKE.Directory_renameFile(swigCPtr, from, to);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public virtual OutputStream createFile(string name) {
    IntPtr cPtr = libCLcsharpPINVOKE.Directory_createFile(swigCPtr, name);
    OutputStream ret = (cPtr == IntPtr.Zero) ? null : new OutputStream(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual void close() {
    libCLcsharpPINVOKE.Directory_close(swigCPtr);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

}

}
