Move FileUtils to file package and define more file util functions

A lot of utils have been defined now that can be used to safely manage files.

The java java.io.File API has poor support for detecting symlinks including broken symlinks. Android implementation also has issues. Check FileTypes.getFileType() function for more info. For this reason, the UnixFileAttributes and related classes has been ported from AOSP to get file attributes and type.

Some file utils and android versions use google's Guava com.google.common.io.MoreFiles library for managing files, specially for safer directory deletion with SecureDirectoryStream.

Some file utils and android versions use org.apache.commons.io.FileUtils for managing files. The library version used is 2.5 and it must not be incremented for compatibility with android version < 8, otherwise runtime crashes will occur.
This commit is contained in:
agnostic-apollo
2021-04-06 06:00:05 +05:00
parent c0323fe816
commit d4fc34ca2d
15 changed files with 3219 additions and 411 deletions

View File

@@ -9,18 +9,22 @@ android {
ndkVersion project.properties.ndkVersion
dependencies {
implementation "androidx.annotation:annotation:1.1.0"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core:1.5.0-beta03'
implementation "androidx.annotation:annotation:1.2.0"
implementation "androidx.core:core:1.5.0-rc01"
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
implementation 'androidx.preference:preference:1.1.1'
implementation "androidx.preference:preference:1.1.1"
implementation "androidx.viewpager:viewpager:1.0.0"
implementation 'com.google.guava:guava:24.1-jre'
implementation "io.noties.markwon:core:$markwon_version"
implementation "io.noties.markwon:ext-strikethrough:$markwon_version"
implementation "io.noties.markwon:linkify:$markwon_version"
implementation "io.noties.markwon:recycler:$markwon_version"
implementation "com.google.guava:guava:24.1-jre"
implementation "io.noties.markwon:core:$markwon_version"
implementation "io.noties.markwon:ext-strikethrough:$markwon_version"
implementation "io.noties.markwon:linkify:$markwon_version"
implementation "io.noties.markwon:recycler:$markwon_version"
implementation project(":terminal-view")
// Do not increment version higher than 2.5 or there
// will be runtime exceptions on android < 8
// due to missing classes like java.nio.file.Path.
implementation "commons-io:commons-io:2.5"
}
defaultConfig {
@@ -95,10 +99,8 @@ android {
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.1'
testImplementation 'org.robolectric:robolectric:4.4'
testImplementation "junit:junit:4.13.1"
testImplementation "org.robolectric:robolectric:4.4"
}
task versionName {