/* * SPDX-FileCopyrightText: 2026 Shiham Abdul Rahman * SPDX-License-Identifier: GPL-3.0-or-later */ package sh.sar.isodroid.data import java.io.File data class IsoFile( val path: String, val name: String, val size: Long ) { companion object { fun fromFile(file: File): IsoFile { return IsoFile( path = file.absolutePath, name = file.name, size = file.length() ) } } val formattedSize: String get() { val kb = size / 1024.0 val mb = kb / 1024.0 val gb = mb / 1024.0 return when { gb >= 1.0 -> String.format("%.2f GB", gb) mb >= 1.0 -> String.format("%.2f MB", mb) kb >= 1.0 -> String.format("%.2f KB", kb) else -> "$size B" } } }