Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Tomas Klubal
    @blondacz
    Hello, can u pls tell me how do I read a zip file with one entry from classpath and map it to string? Thx
    Pathikrit Bhowmick
    @pathikrit
    @blondacz : What do you mean by mapping to String?
    Eric Peters
    @er1c
    @pathikrit got a few PRs put in, not sure what you prefer, bigger or smaller PRs? should I ask you about features before submitting a PR?
    Pathikrit Bhowmick
    @pathikrit
    Smaller PRs and yeah feel free to message me
    Eric Peters
    @er1c
    What's up with the CI, seems like it just keeps running lol
    Eric Peters
    @er1c
    Draft PR for a bunch of IO stuff: pathikrit/better-files#431
    Pathikrit Bhowmick
    @pathikrit
    Great thanks! Will take a look and comment/merge as necessary!
    Eric Peters
    @er1c
    definitely not ready for merge :)
    I have a TODO to add some notes and try and explain the various functionality, the tests are the best resources
    oh the non "big pr" should be fine :)
    Alexander Aumann
    @aumann
    Hi, I've seen that JDK 8 has been removed from tests from 3.9.0 onwards. Does this mean better-files will not work as expected on Java 8 anymore?
    Alexander Aumann
    @aumann
    Ah, ok. I've found pathikrit/better-files#417 -- i.e. it should work I guess?
    Pathikrit Bhowmick
    @pathikrit
    Eric Peters
    @er1c
    @pathikrit not sure if you had a chance to glance at the resource PR to get an initial impression on functionality? One idea I just had was making a better-resources instead of adding to better.files.resources, not sure if you have an initial impression? There is definitely some overlap on compression stuff, I haven't had a chance yet to see how much can be refactored
    the "Scala I/O f or humans" does feel like it would align with the goals if its not just File i/o (e.g. InputStreams/etc)
    Pathikrit Bhowmick
    @pathikrit
    I agree - I plan to take a look at the larger PRs later this week
    Eric Peters
    @er1c
    Eric Peters
    @er1c
    @pathikrit any chance to review the AnyVal PR?
    Noe Alejandro Perez Dominguez
    @osocron
    This message was deleted
    Noe Alejandro Perez Dominguez
    @osocron

    Hello 👋 I'm writing a small library and I'm trying to read .json resource files without knowing the names of all the files in advance. It works fine locally but when I publish the library and call it from another application I get errors like: java.nio.file.FileSystemNotFoundException. This is how I'm finding the files currently:

      private val dir = File(Resource.getUrl("property.json"))
      private val matches: Iterator[File] = dir.parent.glob("**/*.json", includePath = false)

    Any help would be much appreciated!

    Pathikrit Bhowmick
    @pathikrit
    I don't think you can glob a resource url! This has nothing to do with better-files but JARs in general. Try in vanilla Java or Scala without better-files you will get same error.
    1 reply
    Ibrahim Moufti
    @Mouftizo

    Hello everyone : ) this is my first time using better-files, so apologies in advance if the question is too basic.

    My main objective is to write JSON lines to a file efficiently while maintaining referential transparency (nice to have).

    I have two main questions:

    1. Is writing to the file line by line efficient? I am assuming that having some sort of a buffer or a batch is faster than writing line by line, and I am wondering if I can use better-files to write to files in bulk
    2. How can I maintain referential transparency while writing to the file? (to my understanding I need to wrap part of the code in an IO Monad, but I am not sure what is the correct way to do this or how to run it safely). Further readings are welcome. (again, that is nice to have)

    I have created some sample code to show what I have reached so far in my code (only a snippet):

    
    import io.circe.generic.auto._, io.circe.syntax._
    
    for (u <- someList) println(u.asJson.noSpaces)
    // resulting Json (sample):
    // {"id":"1","name":"Mr Foo","roles":["Chief Foo Officer"],"phone_number":null}
    // {"id":"2","name":"Mr Bar","roles":["Chief Bar Officer"],"phone_number":null}
    // .....
    Pathikrit Bhowmick
    @pathikrit
    @Mouftizo : No writing line by line is inefficient. You should use a print writer to open a stream and write to stream. To make it referentially transparent, simply wrap in in IO. Here is an example:
      import better.files._
      import cats.effect._
    
      def write(file: File, lines: List[String]): IO[Unit] = IO {
        for {
          writer <- file.printWriter()
          line <- lines
        } writer.println(line)
      }
    1 reply
    Oliver Schrenk
    @oschrenk

    Is there some way to remove a parent tree from a file, sort of making a relative path?

    I have

    val base  = File("/Users/Oliver/Downloads")
    val other = File("/Users/Oliver/Downloads/other")

    and I want something like

    println(base.resolve(other))
    /other
    Francois Armand
    @fanf
    Hello! I was wondering if there was some utilities to set unix rights in a shorter way than:
      val defaultFolderPermissions = Set[PosixFilePermission](PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE
                                                      , PosixFilePermission.GROUP_READ, PosixFilePermission.GROUP_EXECUTE)
    something like file.setPerms(" u-x,u+rwX,g-wx,g+rX,o-rwx") (or with the binary representation) ?
    Francois Armand
    @fanf
    in related usability method: is there an utility to recursively create parent directories if they don't exist (with some rights)? (I can do it, it's just the coming from FileUtils.write(path, string), I'm used to have these parent directories created)