diff --git a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/AmazeFile.kt b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/AmazeFile.kt
index 789cd803d9..0eade8f090 100644
--- a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/AmazeFile.kt
+++ b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/AmazeFile.kt
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
package com.amaze.filemanager.file_operations.filesystem.filetypes
import android.os.Parcel
@@ -134,7 +135,7 @@ class AmazeFile : Comparable {
object AmazeFileParceler : Parceler {
override fun create(parcel: Parcel): AmazeFile =
- AmazeFile(parcel.readString() ?: "")
+ AmazeFile(parcel.readString() ?: "")
override fun AmazeFile.write(parcel: Parcel, flags: Int) {
parcel.writeString(absolutePath)
@@ -257,7 +258,7 @@ class AmazeFile : Comparable {
* `child` pathname string is taken to denote either a directory or a file. If the
* `child` pathname string is absolute then it is converted into a relative pathname in
* a system-dependent way. If `parent` is the empty string then the new `AmazeFile
- ` * instance is created by converting `child` into an abstract pathname and
+ ` * instance is created by converting `child` into an abstract pathname and
* resolving the result against a system-dependent default directory. Otherwise each pathname
* string is converted into an abstract pathname and the child abstract pathname is resolved
* against the parent.
@@ -814,7 +815,9 @@ class AmazeFile : Comparable {
* @see java.nio.file.Files.newDirectoryStream
*/
fun listFiles(
- filter: AmazeFilenameFilter?, contextProvider: ContextProvider): Array? {
+ filter: AmazeFilenameFilter?,
+ contextProvider: ContextProvider
+ ): Array? {
val ss = list(contextProvider) ?: return null
val files = ArrayList()
for (s in ss) if (filter == null || filter.accept(this, s)) files.add(AmazeFile(s!!, this))
@@ -888,8 +891,10 @@ class AmazeFile : Comparable {
return false
}
val parent = canonFile.parentFile
- return (parent != null && (parent.mkdirs(contextProvider) || parent.exists(contextProvider))
- && canonFile.mkdir(contextProvider))
+ return (
+ parent != null && (parent.mkdirs(contextProvider) || parent.exists(contextProvider)) &&
+ canonFile.mkdir(contextProvider)
+ )
}
// Android-changed: Replaced generic platform info with Android specific one.
/**
@@ -930,7 +935,7 @@ class AmazeFile : Comparable {
* precision. The argument will be truncated to fit the supported precision. If the operation
* succeeds and no intervening operations on the file take place, then the next invocation of the
* `[.lastModified]` method will return the (possibly truncated) `time
- ` * argument that was passed to this method.
+ ` * argument that was passed to this method.
*
* @param time The new last-modified time, measured in milliseconds since the epoch (00:00:00 GMT,
* January 1, 1970)
@@ -1205,7 +1210,11 @@ class AmazeFile : Comparable {
val name = prefix + java.lang.Long.toString(n) + suffix
val f = AmazeFile(dir, name)
if (name != f.name || f.isInvalid) {
- if (System.getSecurityManager() != null) throw IOException("Unable to create temporary file") else throw IOException("Unable to create temporary file, $f")
+ if (System.getSecurityManager() != null) {
+ throw IOException("Unable to create temporary file")
+ } else {
+ throw IOException("Unable to create temporary file, $f")
+ }
}
return f
}
@@ -1253,7 +1262,7 @@ class AmazeFile : Comparable {
* @param prefix The prefix string to be used in generating the file's name; must be at least
* three characters long
* @param suffix The suffix string to be used in generating the file's name; may be `null
- ` * , in which case the suffix `".tmp"` will be used
+ ` * , in which case the suffix `".tmp"` will be used
* @param directory The directory in which the file is to be created, or `null` if the
* default temporary-file directory is to be used
* @return An abstract pathname denoting a newly-created empty file
@@ -1263,10 +1272,11 @@ class AmazeFile : Comparable {
*/
@Throws(IOException::class)
fun createTempFile(
- contextProvider: ContextProvider,
- prefix: String,
- suffix: String?,
- directory: AmazeFile?): AmazeFile {
+ contextProvider: ContextProvider,
+ prefix: String,
+ suffix: String?,
+ directory: AmazeFile?
+ ): AmazeFile {
require(prefix.length >= 3) { "Prefix string too short" }
// Android-changed: Handle java.io.tmpdir changes.
@@ -1293,7 +1303,7 @@ class AmazeFile : Comparable {
* @param prefix The prefix string to be used in generating the file's name; must be at least
* three characters long
* @param suffix The suffix string to be used in generating the file's name; may be `null
- ` * , in which case the suffix `".tmp"` will be used
+ ` * , in which case the suffix `".tmp"` will be used
* @return An abstract pathname denoting a newly-created empty file
* @throws IllegalArgumentException If the `prefix` argument contains fewer than three
* characters
@@ -1302,7 +1312,10 @@ class AmazeFile : Comparable {
*/
@Throws(IOException::class)
fun createTempFile(
- contextProvider: ContextProvider, prefix: String, suffix: String?): AmazeFile {
+ contextProvider: ContextProvider,
+ prefix: String,
+ suffix: String?
+ ): AmazeFile {
return createTempFile(contextProvider, prefix, suffix, null)
}
/* -- Basic infrastructure -- */
@@ -1360,4 +1373,4 @@ class AmazeFile : Comparable {
override fun toString(): String {
return path
}
-}
\ No newline at end of file
+}
diff --git a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/AmazeFilesystem.kt b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/AmazeFilesystem.kt
index 0507c2ea43..67f596f91c 100644
--- a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/AmazeFilesystem.kt
+++ b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/AmazeFilesystem.kt
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
package com.amaze.filemanager.file_operations.filesystem.filetypes
import java.io.File
@@ -172,7 +173,7 @@ abstract class AmazeFilesystem {
/**
* Delete the file or directory denoted by the given abstract pathname, returning `true
- ` * if and only if the operation succeeds.
+ ` * if and only if the operation succeeds.
*/
abstract fun delete(f: AmazeFile, contextProvider: ContextProvider): Boolean
@@ -184,7 +185,9 @@ abstract class AmazeFilesystem {
abstract fun list(f: AmazeFile, contextProvider: ContextProvider): Array?
abstract fun getInputStream(f: AmazeFile, contextProvider: ContextProvider): InputStream?
abstract fun getOutputStream(
- f: AmazeFile, contextProvider: ContextProvider): OutputStream?
+ f: AmazeFile,
+ contextProvider: ContextProvider
+ ): OutputStream?
/**
* Create a new directory denoted by the given abstract pathname, returning `true` if
@@ -197,7 +200,10 @@ abstract class AmazeFilesystem {
* pathname, returning `true` if and only if the operation succeeds.
*/
abstract fun rename(
- file1: AmazeFile, file2: AmazeFile, contextProvider: ContextProvider): Boolean
+ file1: AmazeFile,
+ file2: AmazeFile,
+ contextProvider: ContextProvider
+ ): Boolean
/**
* Set the last-modified time of the file or directory denoted by the given abstract pathname,
@@ -356,8 +362,10 @@ abstract class AmazeFilesystem {
}
init {
- useCanonCaches = getBooleanProperty("sun.io.useCanonCaches", useCanonCaches)
- useCanonPrefixCache = getBooleanProperty("sun.io.useCanonPrefixCache", useCanonPrefixCache)
+ useCanonCaches =
+ getBooleanProperty("sun.io.useCanonCaches", useCanonCaches)
+ useCanonPrefixCache =
+ getBooleanProperty("sun.io.useCanonPrefixCache", useCanonPrefixCache)
}
}
-}
\ No newline at end of file
+}
diff --git a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/CloudAmazeFilesystem.kt b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/CloudAmazeFilesystem.kt
index 272d2d0cfd..711aaa39bd 100644
--- a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/CloudAmazeFilesystem.kt
+++ b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/CloudAmazeFilesystem.kt
@@ -17,11 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
package com.amaze.filemanager.file_operations.filesystem.filetypes.cloud
import android.util.Log
-import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFile
+import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.ContextProvider
import com.cloudrail.si.types.CloudMetaData
import java.io.File
@@ -34,7 +35,9 @@ import java.util.*
abstract class CloudAmazeFilesystem : AmazeFilesystem() {
abstract val account: Account
override fun prefixLength(path: String): Int {
- require(path.length != 0) { "This should never happen, all paths must start with OTG prefix" }
+ require(path.isNotEmpty()) {
+ "This should never happen, all paths must start with OTG prefix"
+ }
return super.prefixLength(path)
}
@@ -182,7 +185,11 @@ abstract class CloudAmazeFilesystem : AmazeFilesystem() {
return true // This seems to never fail
}
- override fun rename(file1: AmazeFile, file2: AmazeFile, contextProvider: ContextProvider): Boolean {
+ override fun rename(
+ file1: AmazeFile,
+ file2: AmazeFile,
+ contextProvider: ContextProvider
+ ): Boolean {
val account = account.account ?: return false
account.move(removePrefix(file1.path), removePrefix(file2.path))
return true // This seems to never fail
@@ -221,4 +228,4 @@ abstract class CloudAmazeFilesystem : AmazeFilesystem() {
companion object {
val TAG = CloudAmazeFilesystem::class.java.simpleName
}
-}
\ No newline at end of file
+}
diff --git a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/box/BoxAmazeFilesystem.kt b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/box/BoxAmazeFilesystem.kt
index cbd54e30bc..3b0ac14310 100644
--- a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/box/BoxAmazeFilesystem.kt
+++ b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/box/BoxAmazeFilesystem.kt
@@ -17,13 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
package com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.box
-import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
-import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.box.BoxAmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFile
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.Account
-import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.box.BoxAccount
+import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
object BoxAmazeFilesystem : CloudAmazeFilesystem() {
@JvmStatic
@@ -35,8 +34,8 @@ object BoxAmazeFilesystem : CloudAmazeFilesystem() {
AmazeFile.addFilesystem(this)
}
- override val prefix: String = PREFIX
+ override val prefix: String = PREFIX
override val account: Account
get() = BoxAccount
-}
\ No newline at end of file
+}
diff --git a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/dropbox/DropboxAmazeFilesystem.kt b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/dropbox/DropboxAmazeFilesystem.kt
index 02d8c0869c..299acacc0a 100644
--- a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/dropbox/DropboxAmazeFilesystem.kt
+++ b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/dropbox/DropboxAmazeFilesystem.kt
@@ -17,13 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
package com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.dropbox
-import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
-import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.dropbox.DropboxAmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFile
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.Account
-import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.dropbox.DropboxAccount
+import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
object DropboxAmazeFilesystem : CloudAmazeFilesystem() {
@JvmStatic
@@ -34,8 +33,8 @@ object DropboxAmazeFilesystem : CloudAmazeFilesystem() {
AmazeFile.addFilesystem(this)
}
- override val prefix: String = PREFIX
+ override val prefix: String = PREFIX
override val account: Account
get() = DropboxAccount
-}
\ No newline at end of file
+}
diff --git a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/gdrive/GoogledriveAmazeFilesystem.kt b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/gdrive/GoogledriveAmazeFilesystem.kt
index 9894f40dd3..6a30761b77 100644
--- a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/gdrive/GoogledriveAmazeFilesystem.kt
+++ b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/gdrive/GoogledriveAmazeFilesystem.kt
@@ -17,13 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
package com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.gdrive
-import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
-import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.gdrive.GoogledriveAmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFile
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.Account
-import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.gdrive.GoogledriveAccount
+import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
object GoogledriveAmazeFilesystem : CloudAmazeFilesystem() {
@JvmStatic
@@ -38,4 +37,4 @@ object GoogledriveAmazeFilesystem : CloudAmazeFilesystem() {
override val account: Account
get() = GoogledriveAccount
-}
\ No newline at end of file
+}
diff --git a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/onedrive/OnedriveAmazeFilesystem.kt b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/onedrive/OnedriveAmazeFilesystem.kt
index 5ad411f557..d221bb5d83 100644
--- a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/onedrive/OnedriveAmazeFilesystem.kt
+++ b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/cloud/onedrive/OnedriveAmazeFilesystem.kt
@@ -17,11 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
package com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.onedrive
-import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFile
import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.Account
+import com.amaze.filemanager.file_operations.filesystem.filetypes.cloud.CloudAmazeFilesystem
object OnedriveAmazeFilesystem : CloudAmazeFilesystem() {
@JvmStatic
@@ -36,4 +37,4 @@ object OnedriveAmazeFilesystem : CloudAmazeFilesystem() {
override val account: Account
get() = OnedriveAccount
-}
\ No newline at end of file
+}
diff --git a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/file/FileAmazeFilesystem.kt b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/file/FileAmazeFilesystem.kt
index 5aa79bbc65..971929ba34 100644
--- a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/file/FileAmazeFilesystem.kt
+++ b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/file/FileAmazeFilesystem.kt
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
package com.amaze.filemanager.file_operations.filesystem.filetypes.file
import android.content.ContentValues
@@ -35,7 +36,7 @@ import java.io.*
* This is in in essence calls to UnixFilesystem, but that class is not public so all calls must go
* through java.io.File
*/
-object FileAmazeFilesystem: AmazeFilesystem() {
+object FileAmazeFilesystem : AmazeFilesystem() {
@JvmStatic
val TAG = FileAmazeFilesystem::class.java.simpleName
@@ -159,7 +160,8 @@ object FileAmazeFilesystem: AmazeFilesystem() {
// Try with Storage Access Framework.
if (context != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
val document = getDocumentFile(
- f, true, context, get(context))
+ f, true, context, get(context)
+ )
if (document != null && document.delete()) {
return true
}
@@ -174,8 +176,9 @@ object FileAmazeFilesystem: AmazeFilesystem() {
// Delete the created entry, such that content provider will delete the file.
resolver.delete(
- MediaStore.Files.getContentUri("external"),
- MediaStore.MediaColumns.DATA + "=?", arrayOf(f.absolutePath))
+ MediaStore.Files.getContentUri("external"),
+ MediaStore.MediaColumns.DATA + "=?", arrayOf(f.absolutePath)
+ )
}
return !f.exists(contextProvider)
}
@@ -185,9 +188,12 @@ object FileAmazeFilesystem: AmazeFilesystem() {
val context = contextProvider.getContext()
// Try with Storage Access Framework.
- if (context != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && isOnExtSdCard(f, context)) {
+ if (context != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
+ isOnExtSdCard(f, context)
+ ) {
val document = getDocumentFile(
- f, false, context, get(context)) ?: return true
+ f, false, context, get(context)
+ ) ?: return true
if (document.delete()) {
return true
}
@@ -198,7 +204,7 @@ object FileAmazeFilesystem: AmazeFilesystem() {
val resolver = context!!.contentResolver
try {
val uri = MediaStoreHack.getUriFromFile(f.absolutePath, context)
- ?: return false
+ ?: return false
resolver.delete(uri, null, null)
return !f.exists(contextProvider)
} catch (e: SecurityException) {
@@ -230,7 +236,8 @@ object FileAmazeFilesystem: AmazeFilesystem() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Storage Access Framework
val targetDocument = getDocumentFile(
- f, false, context, get(context)) ?: return null
+ f, false, context, get(context)
+ ) ?: return null
return context.contentResolver.openOutputStream(targetDocument.uri)
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
// Workaround for Kitkat ext SD card
@@ -251,10 +258,12 @@ object FileAmazeFilesystem: AmazeFilesystem() {
val context = contextProvider.getContext()
// Try with Storage Access Framework.
- if (context != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && isOnExtSdCard(f, context)) {
+ if (context != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
+ isOnExtSdCard(f, context)
+ ) {
val preferenceUri = get(context)
val document = getDocumentFile(f, true, context, preferenceUri)
- ?: return false
+ ?: return false
// getDocumentFile implicitly creates the directory.
return document.exists()
}
@@ -269,7 +278,11 @@ object FileAmazeFilesystem: AmazeFilesystem() {
} else false
}
- override fun rename(file1: AmazeFile, file2: AmazeFile, contextProvider: ContextProvider): Boolean {
+ override fun rename(
+ file1: AmazeFile,
+ file2: AmazeFile,
+ contextProvider: ContextProvider
+ ): Boolean {
return File(file1.path).renameTo(File(file2.path))
}
@@ -300,4 +313,4 @@ object FileAmazeFilesystem: AmazeFilesystem() {
override fun hashCode(f: AmazeFile): Int {
return File(f.path).hashCode()
}
-}
\ No newline at end of file
+}
diff --git a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/smb/SmbAmazeFilesystem.kt b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/smb/SmbAmazeFilesystem.kt
index b306406675..3107841a77 100644
--- a/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/smb/SmbAmazeFilesystem.kt
+++ b/file_operations/src/main/java/com/amaze/filemanager/file_operations/filesystem/filetypes/smb/SmbAmazeFilesystem.kt
@@ -17,23 +17,25 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
package com.amaze.filemanager.file_operations.filesystem.filetypes.smb
import android.net.Uri
import android.text.TextUtils
import android.util.Log
-import com.amaze.filemanager.file_operations.filesystem.filetypes.smb.CifsContexts.createWithDisableIpcSigningCheck
-import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFilesystem
-import jcifs.smb.SmbFile
-import jcifs.smb.NtlmPasswordAuthenticator
import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFile
+import com.amaze.filemanager.file_operations.filesystem.filetypes.AmazeFilesystem
import com.amaze.filemanager.file_operations.filesystem.filetypes.ContextProvider
import com.amaze.filemanager.file_operations.filesystem.filetypes.smb.CifsContexts.SMB_URI_PREFIX
-import jcifs.smb.SmbException
+import com.amaze.filemanager.file_operations.filesystem.filetypes.smb.CifsContexts.createWithDisableIpcSigningCheck
import jcifs.SmbConstants
+import jcifs.smb.NtlmPasswordAuthenticator
+import jcifs.smb.SmbException
+import jcifs.smb.SmbFile
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
+import java.lang.Boolean.parseBoolean
import java.lang.IllegalArgumentException
import java.lang.IllegalStateException
import java.net.MalformedURLException
@@ -46,7 +48,7 @@ import java.util.regex.Pattern
* Relative paths are not supported
*
*/
-object SmbAmazeFilesystem: AmazeFilesystem() {
+object SmbAmazeFilesystem : AmazeFilesystem() {
@JvmStatic
val TAG = SmbAmazeFilesystem::class.java.simpleName
@@ -66,7 +68,8 @@ object SmbAmazeFilesystem: AmazeFilesystem() {
path
}
val uri = Uri.parse(processedPath)
- val disableIpcSigningCheck = java.lang.Boolean.parseBoolean(uri.getQueryParameter(PARAM_DISABLE_IPC_SIGNING_CHECK))
+ val disableIpcSigningCheck =
+ parseBoolean(uri.getQueryParameter(PARAM_DISABLE_IPC_SIGNING_CHECK))
val userInfo = uri.userInfo
val noExtraInfoPath: String
noExtraInfoPath = if (path.contains("?")) {
@@ -75,7 +78,7 @@ object SmbAmazeFilesystem: AmazeFilesystem() {
path
}
val context = createWithDisableIpcSigningCheck(path, disableIpcSigningCheck)
- .withCredentials(createFrom(userInfo))
+ .withCredentials(createFrom(userInfo))
return SmbFile(noExtraInfoPath, context)
}
@@ -137,7 +140,9 @@ object SmbAmazeFilesystem: AmazeFilesystem() {
}
override fun prefixLength(path: String): Int {
- require(path.length != 0) { "This should never happen, all paths must start with SMB prefix" }
+ require(path.isNotEmpty()) {
+ "This should never happen, all paths must start with SMB prefix"
+ }
val matcherMetadata = METADATA_PATTERN.matcher(path)
if (matcherMetadata.find()) {
return matcherMetadata.end()
@@ -362,7 +367,11 @@ object SmbAmazeFilesystem: AmazeFilesystem() {
}
}
- override fun rename(file1: AmazeFile, file2: AmazeFile, contextProvider: ContextProvider): Boolean {
+ override fun rename(
+ file1: AmazeFile,
+ file2: AmazeFile,
+ contextProvider: ContextProvider
+ ): Boolean {
return try {
create(file1.path).renameTo(create(file2.path))
true
@@ -422,4 +431,4 @@ object SmbAmazeFilesystem: AmazeFilesystem() {
// TODO: Find total storage space of SMB when JCIFS adds support
throw NotImplementedError()
}
-}
\ No newline at end of file
+}