java.lang.Object
io.github.amsonix.molt.internal.reschiper.operations.FileOperation

public class FileOperation extends Object
Utility class for various file operations.
  • 构造器详细资料

    • FileOperation

      public FileOperation()
  • 方法详细资料

    • deleteDir

      public static boolean deleteDir(File file)
      Recursively deletes a directory and its contents.
      参数:
      file - The directory to delete.
      返回:
      true if the directory was successfully deleted, false otherwise.
    • uncompress

      public static void uncompress(Path uncompressedFile, Path targetDir) throws IOException
      Uncompressed a ZIP file to a target directory.
      参数:
      uncompressedFile - The ZIP file to uncompress.
      targetDir - The target directory to extract the contents.
      抛出:
      IOException - If an I/O error occurs during the uncompressed.
    • getNetFileSizeDescription

      @NotNull public static @NotNull String getNetFileSizeDescription(long size)
      Gets a human-readable file size description from a file size in bytes.
      参数:
      size - The file size in bytes.
      返回:
      A string representing the file size with appropriate units (B, KB, MB, GB).
    • getFileSizes

      public static long getFileSizes(@NotNull @NotNull File f)
      Gets the size of a file in bytes.
      参数:
      f - The file to get the size of.
      返回:
      The file size in bytes.
    • getZipPathFileSize

      public static long getZipPathFileSize(ZipFile zipFile, ZipEntry zipEntry)
      Gets the size of a file within a ZIP archive.
      参数:
      zipFile - The ZIP file.
      zipEntry - The ZIP entry representing the file.
      返回:
      The size of the file in bytes.
    • copyFileUsingStream

      public static void copyFileUsingStream(File source, @NotNull @NotNull File dest) throws IOException
      Copies a file from a source location to a destination location using streams.
      参数:
      source - The source file to copy.
      dest - The destination file.
      抛出:
      IOException - If an I/O error occurs during the copying process.
    • getFileSimpleName

      @NotNull public static @NotNull String getFileSimpleName(@NotNull @NotNull com.android.tools.build.bundletool.model.ZipPath zipPath)
      Gets the simple name of a file from a ZipPath.
      参数:
      zipPath - The ZipPath representing the file.
      返回:
      The simple name of the file.
    • getFileSuffix

      @NotNull public static @NotNull String getFileSuffix(@NotNull @NotNull com.android.tools.build.bundletool.model.ZipPath zipPath)
      Gets the file suffix (extension) from a ZipPath.
      参数:
      zipPath - The ZipPath representing the file.
      返回:
      The file suffix (extension).
    • getParentFromZipFilePath

      @NotNull public static @NotNull String getParentFromZipFilePath(@NotNull @NotNull String zipPath)
      Gets the parent directory path from a Zip file path.
      参数:
      zipPath - The Zip file path.
      返回:
      The parent directory path.
    • getNameFromZipFilePath

      public static String getNameFromZipFilePath(@NotNull @NotNull String zipPath)
      Gets the name of a file from a Zip file path.
      参数:
      zipPath - The Zip file path.
      返回:
      The file name.
    • getFilePrefixByFileName

      public static String getFilePrefixByFileName(@NotNull @NotNull String fileName)
      Gets the file prefix (name without extension) from a file name.
      参数:
      fileName - The file name.
      返回:
      The file prefix.