commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r819516 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/io/ main/native/include/ test/org/apache/commons/runtime/
Date Mon, 28 Sep 2009 12:53:56 GMT
Author: mturk
Date: Mon Sep 28 12:53:55 2009
New Revision: 819516

URL: http://svn.apache.org/viewvc?rev=819516&view=rev
Log:
Add file io header

Added:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_fileio.h   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystem.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystemProvider.java
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFileSys.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystem.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystem.java?rev=819516&r1=819515&r2=819516&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystem.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystem.java
Mon Sep 28 12:53:55 2009
@@ -27,15 +27,22 @@
 public class FileSystem
 {
 
-    private static FileSystemProvider fs;
+    private static FileSystem  fs = null;
+    private FileSystemProvider fp;
     private FileSystem()
     {
-        // No instance.
+        fp = new FileSystemProvider();
     }
 
     static {
-        fs = new FileSystemProvider();
+        fs = new FileSystem();
     }
+
+    public static FileSystem getInstance()
+    {
+        return fs;
+    }
+
     /**
      * Open file Descriptor.
      * <p>
@@ -45,10 +52,17 @@
      * @return opened file descriptor.
      * @throws IOException on error.
      */
-    public static Descriptor open(File path, EnumSet<FileOpenMode> mode)
+    public Descriptor open(File path, EnumSet<FileOpenMode> mode)
+        throws IOException, IllegalArgumentException
+    {
+        return fp.open(path, mode);
+    }
+
+    public Descriptor open(File path, EnumSet<FileOpenMode> mode,
+                           EnumSet<FileProtection> prot)
         throws IOException, IllegalArgumentException
     {
-        return fs.open(path, mode);
+        return fp.open(path, mode, prot);
     }
 
 }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystemProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystemProvider.java?rev=819516&r1=819515&r2=819516&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystemProvider.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystemProvider.java
Mon Sep 28 12:53:55 2009
@@ -80,7 +80,7 @@
         return open1(path.getPath(), imode, iprot);
     }
 
-    private static native int read0(Descriptor fd);
+    private static native int read0(int fd);
     /**
      * Read one byte from the Descriptor.
      * <p>
@@ -96,10 +96,10 @@
     {
         if (!fd.valid())
             throw new ClosedDescriptorException();
-        return read0(fd);
+        return read0(fd.fd());
     }
 
-    private static native int write0(Descriptor fd, int val);
+    private static native int write0(int fd, int val);
      /**
      * Write one byte to the Descriptor.
      * <p>
@@ -115,7 +115,7 @@
     {
         if (!fd.valid())
             throw new ClosedDescriptorException();
-        return write0(fd, val);
+        return write0(fd.fd(), val);
     }
 
 }

Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_fileio.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_fileio.h?rev=819516&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_fileio.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_fileio.h Mon Sep 28 12:53:55
2009
@@ -0,0 +1,40 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACR_FILEIO_H
+#define _ACR_FILEIO_H
+
+#include "acr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_fileio.h
+ * @brief
+ *
+ * ACR File I/O functions
+ *
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_FILEIO_H */
+

Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_fileio.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFileSys.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFileSys.java?rev=819516&r1=819515&r2=819516&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFileSys.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFileSys.java Mon
Sep 28 12:53:55 2009
@@ -44,7 +44,7 @@
         throws Exception
     {
         File file = new File("ftest1.txt");
-        Descriptor fd = FileSystem.open(file, EnumSet.of(FileOpenMode.RDWR, FileOpenMode.CREATE));
+        Descriptor fd = FileSystem.getInstance().open(file, EnumSet.of(FileOpenMode.RDWR,
FileOpenMode.CREATE));
 
         assertFalse("Descriptor", fd == null);
         System.out.println();
@@ -56,7 +56,7 @@
         throws Exception
     {
         File file = new File("ftest1.txt");
-        Descriptor fd = FileSystem.open(file, EnumSet.of(FileOpenMode.RDWR, FileOpenMode.CREATE,
FileOpenMode.EXCL));
+        Descriptor fd = FileSystem.getInstance().open(file, EnumSet.of(FileOpenMode.RDWR,
FileOpenMode.CREATE, FileOpenMode.EXCL));
         assertFalse("Descriptor", fd != null);
 
     }
@@ -66,7 +66,7 @@
     {
         File file = new File("ftest1.txt");
         file.delete();
-        Descriptor fd = FileSystem.open(file, EnumSet.of(FileOpenMode.RDWR, FileOpenMode.CREATE,
FileOpenMode.EXCL));
+        Descriptor fd = FileSystem.getInstance().open(file, EnumSet.of(FileOpenMode.RDWR,
FileOpenMode.CREATE, FileOpenMode.EXCL));
         assertFalse("Descriptor", fd == null);
 
     }



Mime
View raw message