Skip to content

Commit

Permalink
Refactor: Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghai committed Jan 28, 2024
1 parent 07c47ba commit 7c80d3f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2024 Hai Zhang <dreaming.in.code.zh@gmail.com>
* All Rights Reserved.
*/

package me.zhanghai.android.files.provider.common

import java8.nio.file.attribute.FileTime
import org.threeten.bp.Instant
import kotlin.reflect.KClass

val KClass<FileTime>.EPOCH: FileTime
get() = FileTime.from(Instant.EPOCH)
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import java8.nio.file.attribute.FileTime
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.WriteWith
import me.zhanghai.android.files.provider.common.AbstractContentProviderFileAttributes
import me.zhanghai.android.files.provider.common.EPOCH
import me.zhanghai.android.files.provider.common.FileTimeParceler
import org.threeten.bp.Instant

@Parcelize
internal class ContentFileAttributes(
Expand All @@ -23,7 +23,7 @@ internal class ContentFileAttributes(
) : AbstractContentProviderFileAttributes() {
companion object {
fun from(mimeType: String?, size: Long, uri: Uri): ContentFileAttributes {
val lastModifiedTime = FileTime.from(Instant.EPOCH)
val lastModifiedTime = FileTime::class.EPOCH
val fileKey = uri
return ContentFileAttributes(lastModifiedTime, mimeType, size, fileKey)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ internal object FtpCopyMove {
val timestamp = sourceFile.timestamp
if (timestamp != null) {
try {
Client.setLastModifiedTime(target, sourceFile.timestamp.toInstantCompat())
Client.setLastModifiedTime(target, timestamp.toInstantCompat())
} catch (e: IOException) {
e.printStackTrace()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.WriteWith
import me.zhanghai.android.files.provider.common.AbstractPosixFileAttributes
import me.zhanghai.android.files.provider.common.ByteString
import me.zhanghai.android.files.provider.common.EPOCH
import me.zhanghai.android.files.provider.common.FileTimeParceler
import me.zhanghai.android.files.provider.common.PosixFileMode
import me.zhanghai.android.files.provider.common.PosixFileModeBit
Expand Down Expand Up @@ -41,7 +42,7 @@ internal data class SftpFileAttributes(
lastModifiedTime = FileTime.from(Instant.ofEpochSecond(attributes.mtime))
lastAccessTime = FileTime.from(Instant.ofEpochSecond(attributes.atime))
} else {
lastModifiedTime = FileTime.from(Instant.EPOCH)
lastModifiedTime = FileTime::class.EPOCH
lastAccessTime = lastModifiedTime
}
val creationTime = lastModifiedTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.WriteWith
import me.zhanghai.android.files.provider.common.AbstractBasicFileAttributes
import me.zhanghai.android.files.provider.common.BasicFileType
import me.zhanghai.android.files.provider.common.EPOCH
import me.zhanghai.android.files.provider.common.FileTimeParceler
import me.zhanghai.android.files.provider.smb.client.ShareInformation
import me.zhanghai.android.files.provider.smb.client.ShareType
import org.threeten.bp.Instant

@Parcelize
internal class SmbShareFileAttributes(
Expand All @@ -36,7 +36,7 @@ internal class SmbShareFileAttributes(

companion object {
fun from(shareInformation: ShareInformation, path: SmbPath): SmbShareFileAttributes {
val lastModifiedTime = FileTime.from(Instant.EPOCH)
val lastModifiedTime = FileTime::class.EPOCH
val lastAccessTime = lastModifiedTime
val creationTime = lastModifiedTime
val type = when (shareInformation.type) {
Expand Down

0 comments on commit 7c80d3f

Please sign in to comment.