Skip to content

Commit 7c80d3f

Browse files
committed
Refactor: Minor changes
1 parent 07c47ba commit 7c80d3f

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2024 Hai Zhang <[email protected]>
3+
* All Rights Reserved.
4+
*/
5+
6+
package me.zhanghai.android.files.provider.common
7+
8+
import java8.nio.file.attribute.FileTime
9+
import org.threeten.bp.Instant
10+
import kotlin.reflect.KClass
11+
12+
val KClass<FileTime>.EPOCH: FileTime
13+
get() = FileTime.from(Instant.EPOCH)

app/src/main/java/me/zhanghai/android/files/provider/content/ContentFileAttributes.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import java8.nio.file.attribute.FileTime
1111
import kotlinx.parcelize.Parcelize
1212
import kotlinx.parcelize.WriteWith
1313
import me.zhanghai.android.files.provider.common.AbstractContentProviderFileAttributes
14+
import me.zhanghai.android.files.provider.common.EPOCH
1415
import me.zhanghai.android.files.provider.common.FileTimeParceler
15-
import org.threeten.bp.Instant
1616

1717
@Parcelize
1818
internal class ContentFileAttributes(
@@ -23,7 +23,7 @@ internal class ContentFileAttributes(
2323
) : AbstractContentProviderFileAttributes() {
2424
companion object {
2525
fun from(mimeType: String?, size: Long, uri: Uri): ContentFileAttributes {
26-
val lastModifiedTime = FileTime.from(Instant.EPOCH)
26+
val lastModifiedTime = FileTime::class.EPOCH
2727
val fileKey = uri
2828
return ContentFileAttributes(lastModifiedTime, mimeType, size, fileKey)
2929
}

app/src/main/java/me/zhanghai/android/files/provider/ftp/FtpCopyMove.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ internal object FtpCopyMove {
105105
val timestamp = sourceFile.timestamp
106106
if (timestamp != null) {
107107
try {
108-
Client.setLastModifiedTime(target, sourceFile.timestamp.toInstantCompat())
108+
Client.setLastModifiedTime(target, timestamp.toInstantCompat())
109109
} catch (e: IOException) {
110110
e.printStackTrace()
111111
}

app/src/main/java/me/zhanghai/android/files/provider/sftp/SftpFileAttributes.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import kotlinx.parcelize.Parcelize
1111
import kotlinx.parcelize.WriteWith
1212
import me.zhanghai.android.files.provider.common.AbstractPosixFileAttributes
1313
import me.zhanghai.android.files.provider.common.ByteString
14+
import me.zhanghai.android.files.provider.common.EPOCH
1415
import me.zhanghai.android.files.provider.common.FileTimeParceler
1516
import me.zhanghai.android.files.provider.common.PosixFileMode
1617
import me.zhanghai.android.files.provider.common.PosixFileModeBit
@@ -41,7 +42,7 @@ internal data class SftpFileAttributes(
4142
lastModifiedTime = FileTime.from(Instant.ofEpochSecond(attributes.mtime))
4243
lastAccessTime = FileTime.from(Instant.ofEpochSecond(attributes.atime))
4344
} else {
44-
lastModifiedTime = FileTime.from(Instant.EPOCH)
45+
lastModifiedTime = FileTime::class.EPOCH
4546
lastAccessTime = lastModifiedTime
4647
}
4748
val creationTime = lastModifiedTime

app/src/main/java/me/zhanghai/android/files/provider/smb/SmbShareFileAttributes.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import kotlinx.parcelize.Parcelize
1111
import kotlinx.parcelize.WriteWith
1212
import me.zhanghai.android.files.provider.common.AbstractBasicFileAttributes
1313
import me.zhanghai.android.files.provider.common.BasicFileType
14+
import me.zhanghai.android.files.provider.common.EPOCH
1415
import me.zhanghai.android.files.provider.common.FileTimeParceler
1516
import me.zhanghai.android.files.provider.smb.client.ShareInformation
1617
import me.zhanghai.android.files.provider.smb.client.ShareType
17-
import org.threeten.bp.Instant
1818

1919
@Parcelize
2020
internal class SmbShareFileAttributes(
@@ -36,7 +36,7 @@ internal class SmbShareFileAttributes(
3636

3737
companion object {
3838
fun from(shareInformation: ShareInformation, path: SmbPath): SmbShareFileAttributes {
39-
val lastModifiedTime = FileTime.from(Instant.EPOCH)
39+
val lastModifiedTime = FileTime::class.EPOCH
4040
val lastAccessTime = lastModifiedTime
4141
val creationTime = lastModifiedTime
4242
val type = when (shareInformation.type) {

0 commit comments

Comments
 (0)