-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support -d with .jar paths #3382
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
Changes from 6 commits
507f8d7
8c5bc9e
93b1214
ee7a8f1
4e39251
4a0606a
2e79154
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dotty.tools | ||
package io | ||
|
||
import java.nio.file.{FileSystem, FileSystems} | ||
import java.nio.file.Files | ||
|
||
import java.util.jar._ | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
class JarFS private (private[this] var jarFS: FileSystem) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add some documentation :). |
||
|
||
def getRoot(): AbstractFile = { | ||
val root = jarFS.getRootDirectories.iterator().next() | ||
new PlainDirectory(Directory(root)) | ||
} | ||
|
||
def close() = jarFS.close() | ||
} | ||
|
||
object JarFS { | ||
def create(path: Path): JarFS = { | ||
assert(path.extension == "jar") | ||
val env = Map("create" -> "true").asJava | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add these links in comments if they're useful to understand the code |
||
val jarUri = java.net.URI.create("jar:file:" + path.toAbsolute.path) | ||
new JarFS(FileSystems.newFileSystem(jarUri, env)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure that the jar is empty or all files are rewritten.