Skip to content

Commit 87fa986

Browse files
author
wangshouheng
committed
feat: add file extensions
1 parent 2eb0ba9 commit 87fa986

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

utils-ktx/src/main/java/me/shouheng/utils/ktx/DataKtx.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import androidx.annotation.FloatRange
55
import androidx.annotation.IntRange
66
import me.shouheng.utils.ui.ColorUtils
77

8+
// The kotlin extensions for basic data types.
9+
810
/** Get color with alpha from given color. */
911
@ColorInt fun Int.withAlpha(@FloatRange(from = .0, to = 1.0) alpha: Float, override: Boolean = true): Int {
1012
return ColorUtils.setColorAlpha(this, alpha, override)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package me.shouheng.utils.ktx
2+
3+
import me.shouheng.utils.store.FileUtils
4+
import java.io.File
5+
6+
/**
7+
* The kotlin extensions for [File].
8+
*
9+
* @Author wangshouheng
10+
* @Time 2021/12/19
11+
*/
12+
fun File?.md5(): String = FileUtils.getFileMD5ToString(this)
13+
14+
fun File?.isFile(): Boolean = FileUtils.isFile(this)
15+
16+
fun File?.isDir(): Boolean = FileUtils.isDir(this)
17+
18+
fun File?.rename(name: String): Boolean = FileUtils.rename(this, name)
19+
20+
fun File?.copyTo(dest: File): Boolean = FileUtils.copyFile(this, dest)
21+
22+
fun File?.moveTo(dest: File): Boolean = FileUtils.moveFile(this, dest)
23+
24+
fun File?.delete(): Boolean = FileUtils.delete(this)

0 commit comments

Comments
 (0)