Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Pathikrit Bhowmick
    @pathikrit
    AccessDeniedError means you don't have permission to write to that folder. This is not coming from better-file but from the JDK std lib itself (in the case of I/O from the OS itself)
    moritz bust
    @busti
    Yeah, the thing is, that the first .delete call is successful in deleting the folder but I cannot create any new folder / files in that location until I have restarted the jvm.
    moritz bust
    @busti
    When I recursively delete the files using java.nio it works perfectly fine.
    def deleteAll(file: java.io.File) {
      val contents = file.listFiles()
      if (contents != null) {
        for (f <- contents) {
          FileUtil.deleteAll(f)
        }
      }
     file.delete()
    }
    Pathikrit Bhowmick
    @pathikrit
    Can you paste me your better-files code that does not work and the accompanying NIO code that works? They should do the same thing
    Kunal Kapoor
    @kunalkapoor
    Hey guys I'm new here. I've been looking for a good File IO library for Scala for a long time and I came across this recently. It looks very attractive.
    I also stumbled across https://contributors.scala-lang.org/t/adding-better-files-to-the-scala-platform/340/31 which mentions that better-files could be included in the Scala library itself. However, there is no response since Feb 2017 so I was curious as to the status of that. We all know Scala desperately needs a good IO library, and I'm wondering whether better-files is still on the road to becoming the standard Scala IO utility.
    Pathikrit Bhowmick
    @pathikrit
    There is no plan for better-files becoming part of Scala standard library. Honestly it is better this way since libraries can release improvements/features faster than Scala standard release cadence
    Kunal Kapoor
    @kunalkapoor
    Pathikrit Bhowmick
    @pathikrit
    Yes
    /rgb
    @RalfBarkow_twitter
    Have to add a mimetpye file as the first entry in a ZIP file and it must be stored uncompressed (“Stored” mode). Do I have to specify the compressionLevel and if yes, which one? compressionLevel = 0 ?
    /rgb
    @RalfBarkow_twitter
    Does better-files supports the "compression method", STORED/NO_COMPRESSION=0 ?
    Pathikrit Bhowmick
    @pathikrit
    /rgb
    @RalfBarkow_twitter
    Thanks Pathikrit. 7-Zip shows "Deflate" though with this code:
    val zipFile: File = file.zipTo("test.zip".toFile, compressionLevel = 0)
    Pathikrit Bhowmick
    @pathikrit
    yeah but don't use Int (0), you can use Deflater.DEFAULT_COMPRESSION for clarity
    /rgb
    @RalfBarkow_twitter
    Yes, thank you very much, it's really much easier to read and understand. I use 'compressionLevel = Deflater.NO_COMPRESSION' now but 7-Zip still shows "Deflate"!?
    /rgb
    @RalfBarkow_twitter
    The issue seems to be comparable to dotnet/corefx#29735 : >Currently when a ZipArchive is created and an entry is added with the CompressionLevel set to "no-compression" the file inside the archive is still wrapped in a deflate stream. The deflate stream correctly does not to compress the file.
    Pathikrit Bhowmick
    @pathikrit
    But is this a bug in better-file? It seems its a bug in the unzipper ... unzip works just fine from command line..
    /rgb
    @RalfBarkow_twitter
    unzip -lv test.zip shows the method as Defl:N and not as Stored, so it might be a bug in better-file. (Implicits.scala, line 258: if (level == Deflater.NO_COMPRESSION) out.setMethod(ZipOutputStream.DEFLATED) seems to wrap the file inside the archive in a deflate stream.
    Pathikrit Bhowmick
    @pathikrit
    @RalfBarkow_twitter : That code was added here for some reason - https://github.com/pathikrit/better-files/pull/38/files
    Can you send a pull request perhaps or atleast file an issue with failing test case?
    /rgb
    @RalfBarkow_twitter
    Thanks Pathikrit, will try to write a failing test case and file an issue then but unfortunately I won't be able to do it in the near future (next week is carnival).
    Pathikrit Bhowmick
    @pathikrit
    A failing test or same is enough and I can fix it
    /rgb
    @RalfBarkow_twitter
    Thanks Pathikrit, my problem seems to be that I don't know how to specify the compression method for an individual ZIP file entry, and set it to STORED. (Btw I'm working on that "failing test or same".)
    Pathikrit Bhowmick
    @pathikrit
    Thanks!
    Just put what your "ideal API" would look like and I can work backwords from there
    /rgb
    @RalfBarkow_twitter
    How about val zipFile: File = file.zipTo("test.iirds").toFile.stored ?
    Pathikrit Bhowmick
    @pathikrit
    What does .stored mean?
    /rgb
    @RalfBarkow_twitter
    It should set the compression method to STORED.
    /rgb
    @RalfBarkow_twitter
    val zipFile: File = file.zipTo("test.iirds".toFile).setCompressionMethod(STORED)
    /rgb
    @RalfBarkow_twitter
    According to https://en.wikipedia.org/wiki/Zip_(file_format)#Compression_methods , the .ZIP File Format Specification documents the following compression methods: Store (no compression), ...
    I would like to use .store to specify the compression method for an individual ZIP file entry, and set it to STORED.
    /rgb
    @RalfBarkow_twitter
    Pathikrit Bhowmick
    @pathikrit
    Ok thanks for the pointer. Will take a look
    Philippe Derome
    @phderome
    I am curious to see whether creating tar balls or extracting them is within mandate or roadmap of this library or whether people have pointers for this (other than Process API or haoyi's os API which work well).
    Is there any plan or consideration to include setfacl and getfacl interfaces to handle more complex permission schemes than what chmod allows?
    Pathikrit Bhowmick
    @pathikrit
    @phderome : Is tar balls is definately in scope of this project. Can you file an issue? PRs welcome too :)
    Philippe Derome
    @phderome
    I don't really feel up to the task to contribute to be honest. I'll submit issue. I heard that tar technically is GNU and not completely UNIX portable. I assume that it does not bother you or won't stop you.
    Philippe Derome
    @phderome
    so I see you noticed today it was a duplicate...
    Bloznelis
    @Bloznelis
      def canonicalPath: String =
        toJava.getAbsolutePath
    Hello, is this intended?
    since cannonicalFile is expressed like this:
      def canonicalFile: File =
        toJava.getCanonicalFile.toScala
    Pathikrit Bhowmick
    @pathikrit
    @Bloznelis : yes that is intended
    Sait Sami Kocataş
    @Deliganli

    hi Guys

    when I give a config string like below

    File("~/some/directory")

    it outputs;
    in windows: C:\Users\myuser\projects\myproject\~\some\directory
    in linux : /home/myuser/projects/myproject/~/some/directory

    I would expect it to output;
    in windows: C:\Users\myuser\some\directory
    in linux: /home/myuser/some/directory

    but File.home is pointing to correct directory
    projects/myproject is the classpath of the running application

    am I doing something wrong?

    Pathikrit Bhowmick
    @pathikrit
    @Deliganli : ~ is not a standard construct. Try File.currentWorkingDirectory / "some" / "directory"
    Sait Sami Kocataş
    @Deliganli

    @pathikrit thanks

    I needed to implement something for my usage below

    val PathRegex = """^(?:\~\/)(\.?.*)""".r
    
      implicit class FileAugmentations(file: String) {
    
        def toFile: File = file match {
          case PathRegex(paths) =>
            File.home / paths
          case absolute =>
            File(absolute)
        }
      }

    issue is I will be getting the strings from config files so cannot use code until I reason with the string

    Pathikrit Bhowmick
    @pathikrit
    @Deliganli : Yes it won't work. I don't think it is a issue with better-files but the JDK itself. Try using vanilla java.io.File or java.nio.Path and see if it works there? If yes, let me know ...
    iOgre
    @iOgre_gitlab
    Greetings!
    Why File("zzz").changeExtensionTo("ddd").name gives "zzz" and not "zzz.ddd" ?
    Pathikrit Bhowmick
    @pathikrit
    Because zzz does not have a extension already - I think you are right - this should give zzz.ddd