Skip to content

Conversation

@armanbilge
Copy link
Member

@armanbilge armanbilge commented Jul 11, 2021

Picking up from #2453.

This PR introduces a new PosixFiles typeclass, currently implemented only for Node.js. It is closely modeled on Node.js's fs module but otherwise shouldn't be specific to Node.js at all. I hope future work will implement it for JVM.

For the sake of offering some platform-agnostic API, I also introduced a ReadFiles typeclass which both Files and PosixFiles extend. File-reading seems both safe and straightforward enough to do in a platform-agnostic manner. I'd love to see a similar WriteFiles typeclass as well, but it would have to be carefully implemented to get right the semantics of open/create/append/truncate etc.

Both new typeclasses are sealed to give us some room to iterate on these APIs.

For testing, I copy-pastad the JVM file suite and re-worked for JS. So, essentially anything we can do on JVM we can do on JS, just with different semantics.

I also slipped in the Unix sockets implementation now that File APIs are available.

The only thing missing is a Watcher implementation. We can definitely do this on Node.js as well, but at a first glance seems fairly complicated to implement and I don't want the good stuff here blocked by it. So, I'll finish it off in one more PR.

Thanks in advance for feedback and reviews.

@armanbilge armanbilge marked this pull request as ready for review July 18, 2021 15:09
@@ -0,0 +1,36 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

Can you rename this file to something else? It will conflict with folks using editor quick open features for Stream.scala

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, done. Thanks!

@mpilquist mpilquist merged commit f381f6a into typelevel:main Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants