Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for a large subset of java.nio #694

Merged
merged 116 commits into from May 21, 2017

Conversation

@Duhemm
Copy link
Contributor

@Duhemm Duhemm commented May 3, 2017

This doesn't include support for file watches (e.g. Path is not Watchable), and PathMatcher supports only the regex syntax. I'll open issues for those if we decide to merge this as it is now.

Option(readLine()) match {
case None => SStream.empty
case Some(line) => line #:: toScalaStream()
}
Copy link
Contributor

@allanrenucci allanrenucci May 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readLine() match {
  case null => SStream.empty
  case line => line #:: toScalaStream()
}

Loading

@Duhemm Duhemm force-pushed the topic/java-nio-file-only branch 2 times, most recently from 20f5e08 to eb34cd3 May 8, 2017
Copy link
Member

@densh densh left a comment

Needs a rebase due to conflicting changes in RandomAccessFile.scala, but otherwise this looks like a splendid work @Duhemm ! 👍

Loading

Duhemm added 22 commits May 20, 2017
Currently it only supports `regex` syntax.
Hopefully this will solve the linking errors
As a rule of thumb, `java.nio.file.Files` should call methods defined on
the system specific implementations, not the other way around. This
commit moves the actual definition of `newDirectoryStream`, other
methods to come in subsequent commits.
This change uncovered two bugs in `RandomAccessFile` and
`FileChannelImpl`:

 - In `FileChannelImpl`, the `OpenOptions` were not used correctly in
   some cases
 - In `RandomAccessFile`, `setLength` would silently fail if the file
   was opened for reading only.
@Duhemm Duhemm force-pushed the topic/java-nio-file-only branch from eb34cd3 to c47b27e May 20, 2017
@Duhemm
Copy link
Contributor Author

@Duhemm Duhemm commented May 20, 2017

Done!

Loading

densh
densh approved these changes May 21, 2017
@densh
Copy link
Member

@densh densh commented May 21, 2017

LGTM!

Loading

@densh densh merged commit 7e8afe3 into scala-native:master May 21, 2017
1 check passed
Loading
muxanick added a commit to muxanick/scala-native that referenced this issue May 25, 2017
* Starting on `java.nio.channels`

* Fix `MapMode`

* Scaffolding for AsynchronousChannel

* Add `BasicFileAttributes`, `FileTime`.

* Add `DosFileAttributes`

* Add `CopyOption`

* Add `FileSystem`

* Add `PosixFilePermission`

* Add `FileAttribute`

* Add `PosixFileAttributes`

* Add `{User,Group,}Principal`

* fixup

* Add scaffolding for java.nio

This commit contains lots of half-implemented classes and functions, and
almost nothing is tested.

Now that I have something that can compile for simple examples, I can
start testing and implementing everything.

* Test for `Path.getFileName`

* Fix `PathsSuite`

That was embarrassing.

* Test for `Path.subpath`

* Test and fix `Path.getParent`

* format

* Test `Path.getRoot`

* Tests for `Path.isAbsolute`

* Tests for `Path.iterator`

* Tests and fix for `Path.normalize`

* Tests and fix `Path.startsWith`

* Tests and fixes for `Path.relativize`

* Tests and fix for `Path.resolve`

* Tests and fix for `Path.resolveSibling`

* format

* Fix `FileOutputStream`: create file

* First test for `Files.copy`

* Fix and tests for `Files.copy`

* Add and test `Files.createSymbolicLink`

* Tests and fix for `Files.exists`

* Add and test `Files.createDirectory`

* Add and test `Files.createDirectories`

* Add and test `Files.createFile`

* Add and test `Files.createLink`

* Add and test `Files.createTempDirectory`

* Add and test `Files.isRegularFile`

* Add and test `Files.createTempFile`

* Add and test `Files.delete`, `Files.deleteIfExists`

* Add `java.util.function.BiPredicate`

* File visitor

* Revert "File visitor"

This reverts commit b28d002.

* Add and test `Files.list`

* Add and test `Files.readSymbolicLink`

* Add and test `Files.walk`

* File visitor

* Add `EnumSet`

* Add and test `walkFileTree`

* Add and test `Files.find`

* Comment out unimplemented methods

* Add and test `Files.getLastModifiedTime`

* Add support for `FileAttributeView`

* Support `Files.getAttribute`, tests for attribute views

* Test: specify view name in `Files.getAttribute`

* Add and test `Files.getOwner`, `Files.getPosixFilePermissions`

* Some methods that can be forwarded to `java.io.File`

* Add and tests `Files.lines`

* Add `newBufferedWriter`

* BufferedWriter: Flush before closing

* Add and test `Files.write`

* Add `newInputStream`, `newOutputStream`

* Add and test `Files.move`

* Support and test for setting file attributes

* Fix permissions of files created by `RandomAccessFile`

* Basic support and test for `FileChannel`

* Add `UserPrincipalLookupService`

* Scaffolding for supporting file watch

* Fix FileChannel.MapMode

* Add `FileLock`

* Add `Instant.now()`

* Add channel exceptions

* Add `MappedByteBuffer`

* Format

* Naive implementation of `ArrayList`

* Add and test `Files.readAllLines`

* Add and test `Files.readAllBytes`

* Add `StandardWatchEventKinds`

* Add `PathMatcher`

* Add and test `Files.readAttributes`

* Don't assume file listing orders in `FilesSuite`

* Debugging tests...

* More debugging

* Remove printlns in FilesSuite

* Cleanup channels

* Cleanup FileChannel

* Fix NonWritableChannelException

* Move copy closer to use site

* Move `Files.probeContent`

* Add and test `Paths.get(URI)`

* Support `DirectoryStream`

* Support and test `Files.newOutputStream`

* Support `FileSystemProvider.newInputStream`

* Support `Files.readAttributes(Path, String, ...)`

* Support `FileSystemProvider.readAttributes`

* Cleanup in UnixFileSystemProvider

* Remove unimplemented `Watchable` methods

* Remove custom `split` impl in `java.io.File`

* Remove custom split in `UnixPath`

* Remove mem alloc from `grp.c`

* Don't allocate memory in `pwd.c`

* Don't allocate memory in `statvfs.c`

* Remove comment

* Remove `Principal.implies`

* Fix and test for `java.util.stream`

* Remove `FileSystem.getUserPrincipalLookupService()`

* Support and test `PathMatcher`

Currently it only supports `regex` syntax.

* Remove naive ArrayList impl

* Format C sources

* Remove java to scala conversions from AbstractList

Hopefully this will solve the linking errors

* Support `Stream.filter`

* Move `newDirectoryStream` to `FileSystemProvider`

As a rule of thumb, `java.nio.file.Files` should call methods defined on
the system specific implementations, not the other way around. This
commit moves the actual definition of `newDirectoryStream`, other
methods to come in subsequent commits.

* Move `newInputStream` to `FileSystemProvider`

* Implement `newInputStream` as per the spec

* Move `newOutputStream` to `FileSystemProvider`

This change uncovered two bugs in `RandomAccessFile` and
`FileChannelImpl`:

 - In `FileChannelImpl`, the `OpenOptions` were not used correctly in
   some cases
 - In `RandomAccessFile`, `setLength` would silently fail if the file
   was opened for reading only.

* Move `newByteChannel` to `FileSystemProvider`
@zaneli zaneli mentioned this pull request May 27, 2017
@Duhemm Duhemm deleted the topic/java-nio-file-only branch Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants