src/share/classes/java/io/FileInputStream.java

Print this page
rev 9260 : imported patch io-events-path

@@ -49,10 +49,13 @@
 class FileInputStream extends InputStream
 {
     /* File Descriptor - handle to the open file */
     private final FileDescriptor fd;
 
+    /* The path of the referenced file (null if the stream is created with a file descriptor) */
+    private final String path;
+
     private FileChannel channel = null;
 
     private final Object closeLock = new Object();
     private volatile boolean closed = false;
 

@@ -126,10 +129,11 @@
         if (file.isInvalid()) {
             throw new FileNotFoundException("Invalid file path");
         }
         fd = new FileDescriptor();
         fd.attach(this);
+        path = name;
         open(name);
     }
 
     /**
      * Creates a <code>FileInputStream</code> by using the file descriptor

@@ -162,10 +166,11 @@
         }
         if (security != null) {
             security.checkRead(fdObj);
         }
         fd = fdObj;
+        path = null;
 
         /*
          * FileDescriptor is being shared by streams.
          * Register this stream with FileDescriptor tracker.
          */

@@ -343,11 +348,11 @@
      * @spec JSR-51
      */
     public FileChannel getChannel() {
         synchronized (this) {
             if (channel == null) {
-                channel = FileChannelImpl.open(fd, true, false, this);
+                channel = FileChannelImpl.open(fd, path, true, false, this);
             }
             return channel;
         }
     }