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

[Feature Request] Ability to list ResourcePath #355

Open
joan38 opened this issue Feb 13, 2025 · 2 comments
Open

[Feature Request] Ability to list ResourcePath #355

joan38 opened this issue Feb 13, 2025 · 2 comments

Comments

@joan38
Copy link
Contributor

joan38 commented Feb 13, 2025

It would be cool if we could do the same as:

  def apply(relativePath: RelPath): Seq[Array[Byte]] =
    val fixtureDirPath = os.resource / "fixtures" / relativePath
    val uri = getClass.getClassLoader.getResource(fixtureDirPath.segments.mkString("/")).toURI
    val path =
      if uri.getScheme == "jar"
      then FileSystems.newFileSystem(uri, Map.empty[String, Any].asJava).getPath(fixtureDirPath.toString)
      else Paths.get(uri)

    Files
      .list(path)
      .iterator()
      .asScala
      .map(path => os.read.bytes(os.Path(path)))
      .toSeq

Thanks

@joan38 joan38 changed the title [Feature request] Ability to list ResourcePath [Feature Request] Ability to list ResourcePath Feb 13, 2025
@lihaoyi
Copy link
Member

lihaoyi commented Feb 20, 2025

@joan38 could you explain what it is you are trying to do?

@joan38
Copy link
Contributor Author

joan38 commented Feb 20, 2025

It sounds like with os-lib we cannot list or walk a folder in resources.
In this example I'm even walking into jars that are in resources.

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

No branches or pull requests

2 participants