plasma-umass / doppio

Breaks the browser language barrier (includes a plugin-free JVM).
http://plasma-umass.github.io/doppio-demo
MIT License
2.16k stars 174 forks source link

Track position on file descriptors separate from `FileDescriptor` objects #476

Closed jvilk closed 7 years ago

jvilk commented 7 years ago

Java has two different APIs for accessing the file system: java.io and java.nio.

Naturally, Java contains some internal, trusted conversion functions that create FileDescriptor objects from raw file descriptors, and vice versa.

Since Java exposes an API for retrieving a file descriptor's position and Node.js does not, we manually track a file descriptor's file position... in a FileDescriptor object. Which poses an issue: when converted into a raw file descriptor (or created from a raw file descriptor), we do not know the descriptor's position.

Instead, we should maintain a simple map from open descriptors to positions. We can update this map whenever we manipulate a file descriptor.

This will fix our currently-failing NioPathsTest.