Class FilesystemManager

java.lang.Object
com.idmedia.translationstudio.impl.util.FilesystemManager
All Implemented Interfaces:
IFilesystemManager

public class FilesystemManager extends Object implements IFilesystemManager
bundles operations on the filesystem
Author:
I-D Media AG
  • Constructor Details

    • FilesystemManager

      public FilesystemManager()
  • Method Details

    • removeDirectory

      public boolean removeDirectory(@Nullable File pDirectory)
      Delete a directory
      Specified by:
      removeDirectory in interface IFilesystemManager
      Parameters:
      pDirectory - Input Directory
      Returns:
      success state
    • removeFile

      public static boolean removeFile(File pFile)
      Delete a File
      Parameters:
      pFile - Input Directory
      Returns:
      success state
    • writeFileUtf8

      public boolean writeFileUtf8(@Nullable String sFile, @Nullable String sContent)
      Write a file in UTF-8
      Specified by:
      writeFileUtf8 in interface IFilesystemManager
      Parameters:
      sFile - Target File, will be created if necessary
      sContent - Content
      Returns:
      success state
    • writeFileUtf8

      public boolean writeFileUtf8(@Nullable String sTargetFile, @Nullable String sContent, boolean bAppendData)
      Write a file in UTF-8
      Specified by:
      writeFileUtf8 in interface IFilesystemManager
      Parameters:
      sTargetFile - Target File, will be created if necessary
      sContent - Content
      bAppendData - Append Data to existing content
      Returns:
      success state
    • writeFileUtf8

      public boolean writeFileUtf8(@Nullable String sTargetFile, @Nullable StringBuilder psContent, boolean bAppend)
      Write a file in UTF-8
      Specified by:
      writeFileUtf8 in interface IFilesystemManager
      Parameters:
      sTargetFile - Target File, will be created if necessary
      psContent - Content
      bAppend - Append to the file if true, otherwise write create new file
      Returns:
      success state
    • writeFileUtf8

      public boolean writeFileUtf8(@Nullable String sTargetFile, @Nullable byte[] pContent, boolean bAppendData)
      Write a file in UTF-8
      Specified by:
      writeFileUtf8 in interface IFilesystemManager
      Parameters:
      sTargetFile - Target File, will be created if necessary
      pContent - Content
      bAppendData - Append Data to existing content
      Returns:
      success state
    • writeFile

      public static boolean writeFile(@Nullable String sTargetFile, @Nullable String sContent, boolean bAppend)
      Write a file in UTF-8
      Parameters:
      sTargetFile - Target File, will be created if necessary
      sContent - Content
      bAppend - if true append to file, otherwise create a new file
      Returns:
      success state
    • writeFile

      public static boolean writeFile(@NotNull File pTargetFile, @NotNull byte[] byteContent, boolean bAppend)
      Write a file in UTF-8
      Parameters:
      pTargetFile - Target File, will be created if necessary
      byteContent - bytes to write
      bAppend - if true append to file, otherwise create a new file
      Returns:
      success state
    • createBackupFile

      public File createBackupFile(File pFileToBackup) throws IOException
      Creates a backup file
      Parameters:
      pFileToBackup -
      Returns:
      backuped file
      Throws:
      IOException
    • deleteFile

      public boolean deleteFile(File pFile)
      Deletes a file
      Specified by:
      deleteFile in interface IFilesystemManager
      Parameters:
      pFile -
      Returns:
      success state
    • renameFile

      public boolean renameFile(File pSrcFile, File pDstFile)
      Rename a file
      Parameters:
      pSrcFile -
      pDstFile -
      Returns:
    • fileExists

      public boolean fileExists(@Nullable File pFile)
      Checks if File exists and is a file
      Specified by:
      fileExists in interface IFilesystemManager
      Parameters:
      pFile - File to be checked
      Returns:
      result
    • readFileAsBytes

      @NotNull public static byte[] readFileAsBytes(@NotNull File pFile)
    • readFileUtf8

      @NotNull public StringBuilder readFileUtf8(@NotNull File pFile)
      Description copied from interface: IFilesystemManager
      Read a file
      Specified by:
      readFileUtf8 in interface IFilesystemManager
      Returns:
    • readFileUtf8AsBuilder

      @NotNull public StringBuilder readFileUtf8AsBuilder(String sPath)
      Read a file in UTF-8
      Specified by:
      readFileUtf8AsBuilder in interface IFilesystemManager
      Parameters:
      sPath - File to be read
      Returns:
      Content or null on error
    • readFileUtf8

      @NotNull public String readFileUtf8(String sPath)
      Read a file in UTF-8
      Specified by:
      readFileUtf8 in interface IFilesystemManager
      Parameters:
      sPath - File to be read
      Returns:
      Content or null on error
    • exists

      public static boolean exists(File pFile)
      Check if a given file exits
      Parameters:
      pFile - File to check
      Returns:
    • exists

      public static boolean exists(String sFileUri)
    • cloneFile

      public static boolean cloneFile(File pSourceFile, File pTargetFile)
      Clone a file
      Parameters:
      pSourceFile - Source file name
      pTargetFile - Target file name
      Returns:
      success state
    • moveFiles

      public boolean moveFiles(@NotNull File pSourceFile, @NotNull File pTargetFile)
      Move source to target file. Target file will overwritten
      Specified by:
      moveFiles in interface IFilesystemManager
      Returns:
    • copyFile

      public boolean copyFile(File pSourceFile, File pTargetFile)
      Copy source to target file. Target file will overwritten
      Specified by:
      copyFile in interface IFilesystemManager
      Returns:
    • cleanTempDirectory

      public void cleanTempDirectory(File pTempDir)
      Cleanup Filesystem

      In debug mode the temporary files are left in place to allow better analysis of the process.

      Specified by:
      cleanTempDirectory in interface IFilesystemManager
      Parameters:
      pTempDir -
    • createTempDirectory

      @Nullable public File createTempDirectory(@NotNull IConfiguration pConfig)
      Description copied from interface: IFilesystemManager
      create a new temporary directory in a given master temp directory

      Specified by:
      createTempDirectory in interface IFilesystemManager
      Returns:
      New Directory Handler or null