Giter Club home page Giter Club logo

Comments (5)

borkdude avatar borkdude commented on June 20, 2024

I still would like to use copy-tree to extract resources from a jar

copy-tree has been written with normal files in mind.

Have you tried the unzip function? jar files are basically just zip files

from fs.

stanislas avatar stanislas commented on June 20, 2024

Thank you for the feedback. Yes, I know the unzip function, but it does not allow to extract a sub tree from the zip/jar file.

A possibility for sub-tree extraction could be an option named sub-tree-root (or similar) to unzip, or, more generically, to have 2 options :include-entry? and resolve-entry to control the behaviour of unzip. For the normal case, these 2 options would be

{:include-entry? (constantly true)
 :resolve-entry (fn [^Path output-path ^Path entry-path]
                  (.resolve output-path entry-path))}

and for sub tree extraction, they would be (where sub-tree-root is the Path to be extracted)

{:include-entry? (fn [^Path entry-path]
                   (fs/starts-with? entry-path sub-tree-root))
 :resolve-entry  (fn [^Path output-path ^Path entry-path]
                   (.resolve output-path (.relativize sub-tree-root entry-path)))}

from fs.

borkdude avatar borkdude commented on June 20, 2024

Sounds like an idea. With zip we already have the option :path-fn which resolves a path to a zip entry. In hindsight :path->entry would have been a better name (and we can support this new name while deprecating the old one).

Then we could have: :unzip-entry? and :entry->path to do what you suggest above.

from fs.

stanislas avatar stanislas commented on June 20, 2024

nice.
should I give a try at a PR?

from fs.

borkdude avatar borkdude commented on June 20, 2024

yes please!

from fs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.