8000 [Feature Request] Ability to list ResourcePath · Issue #355 · com-lihaoyi/os-lib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Feature Request] Ability to list ResourcePath #355
Open
@joan38

Description

@joan38

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0