Class FileSystemUtils

java.lang.Object
org.eclipse.dirigible.commons.api.helpers.FileSystemUtils

public class FileSystemUtils
extends Object
The File System Utils.
  • Field Details

  • Constructor Details

  • Method Details

    • saveFile

      public static void saveFile​(String workspacePath, byte[] content) throws FileNotFoundException, IOException
      Save file.
      Parameters:
      workspacePath - the workspace path
      content - the content
      Throws:
      FileNotFoundException - the file not found exception
      IOException - Signals that an I/O exception has occurred.
    • loadFile

      public static byte[] loadFile​(String workspacePath) throws FileNotFoundException, IOException
      Load file.
      Parameters:
      workspacePath - the workspace path
      Returns:
      the byte[]
      Throws:
      FileNotFoundException - the file not found exception
      IOException - Signals that an I/O exception has occurred.
    • moveFile

      public static void moveFile​(String workspacePathOld, String workspacePathNew) throws FileNotFoundException, IOException
      Move file.
      Parameters:
      workspacePathOld - the workspace path old
      workspacePathNew - the workspace path new
      Throws:
      FileNotFoundException - the file not found exception
      IOException - Signals that an I/O exception has occurred.
    • copyFile

      public static void copyFile​(String srcPath, String destPath) throws FileNotFoundException, IOException
      Copy file.
      Parameters:
      srcPath - the src path
      destPath - the dest path
      Throws:
      FileNotFoundException - the file not found exception
      IOException - Signals that an I/O exception has occurred.
    • copyFolder

      public static void copyFolder​(String srcPath, String destPath) throws FileNotFoundException, IOException
      Copy folder.
      Parameters:
      srcPath - the src path
      destPath - the dest path
      Throws:
      FileNotFoundException - the file not found exception
      IOException - Signals that an I/O exception has occurred.
    • removeFile

      public static void removeFile​(String workspacePath) throws FileNotFoundException, IOException
      Removes the file.
      Parameters:
      workspacePath - the workspace path
      Throws:
      FileNotFoundException - the file not found exception
      IOException - Signals that an I/O exception has occurred.
    • createFolder

      public static boolean createFolder​(String workspacePath)
      Creates the folder.
      Parameters:
      workspacePath - the workspace path
      Returns:
      true, if successful
    • createFile

      public static boolean createFile​(String workspacePath) throws IOException
      Creates the file.
      Parameters:
      workspacePath - the workspace path
      Returns:
      true, if successful
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • getExtension

      public static String getExtension​(String workspacePath) throws IOException
      Gets the extension.
      Parameters:
      workspacePath - the workspace path
      Returns:
      the extension
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • getOwner

      public static String getOwner​(String workspacePath) throws IOException
      Gets the owner.
      Parameters:
      workspacePath - the workspace path
      Returns:
      the owner
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • getModifiedAt

      public static Date getModifiedAt​(String workspacePath) throws IOException
      Gets the modified at.
      Parameters:
      workspacePath - the workspace path
      Returns:
      the modified at
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • createFoldersIfNecessary

      public static void createFoldersIfNecessary​(String workspacePath)
      Creates the folders if necessary.
      Parameters:
      workspacePath - the workspace path
    • exists

      public static boolean exists​(String location)
      Exists.
      Parameters:
      location - the location
      Returns:
      true, if successful
    • directoryExists

      public static boolean directoryExists​(String location)
      Directory exists.
      Parameters:
      location - the location
      Returns:
      true, if successful
    • fileExists

      public static boolean fileExists​(String location)
      File exists.
      Parameters:
      location - the location
      Returns:
      true, if successful
    • isDirectory

      public static boolean isDirectory​(String location)
      Checks if is directory.
      Parameters:
      location - the location
      Returns:
      true, if is directory
    • listFiles

      public static File[] listFiles​(File directory) throws IOException
      List files including symbolic links.
      Parameters:
      directory - the source directory
      Returns:
      the list of files
      Throws:
      IOException - IO error
    • forceCreateDirectory

      public static File forceCreateDirectory​(String firstSegment, String... segments) throws IOException
      Force create directory and all its parents.
      Parameters:
      firstSegment - the first segment
      segments - the rest segments
      Returns:
      the resulting path
      Throws:
      IOException - IO error
    • deleteDirectory

      public static void deleteDirectory​(String firstSegment, String... segments) throws IOException
      Delete directory.
      Parameters:
      firstSegment - the first segment
      segments - the segments
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • getDirectory

      public static File getDirectory​(String firstSegment, String... segments)
      Returns the directory by segments.
      Parameters:
      firstSegment - the first segment
      segments - the rest segments
      Returns:
      the resulting path
    • generateGitRepositoryName

      public static String generateGitRepositoryName​(String repositoryURI)
      Generate the local repository name.
      Parameters:
      repositoryURI - the URI odf the repository
      Returns:
      the generated local name
    • getGitDirectory

      public static File getGitDirectory​(String user, String workspace)
      Get the directory for git.
      Parameters:
      user - logged-in user
      workspace - the workspace
      Returns:
      the directory
    • getGitRepositories

      public static List<String> getGitRepositories​(String user, String workspace)
      Gets the git repositories.
      Parameters:
      user - the user
      workspace - the workspace
      Returns:
      the git repositories
    • getGitDirectory

      public static File getGitDirectory​(String user, String workspace, String repositoryURI)
      Get the directory for git.
      Parameters:
      user - logged-in user
      workspace - the workspace
      repositoryURI - the repository URI
      Returns:
      the directory
    • getGitDirectoryByRepositoryName

      public static File getGitDirectoryByRepositoryName​(String user, String workspace, String repositoryName)
      Get the directory for git.
      Parameters:
      user - logged-in user
      workspace - the workspace
      repositoryName - the repository URI
      Returns:
      the directory
    • getGitDeepDirectoryByRepositoryName

      public static File getGitDeepDirectoryByRepositoryName​(String user, String workspace, String repositoryName)
      Get the directory for git for deep projects.
      Parameters:
      user - logged-in user
      workspace - the workspace
      repositoryName - the repository URI
      Returns:
      the directory
    • getGitRepositoryProjects

      public static List<String> getGitRepositoryProjects​(String user, String workspace, String repositoryName)
      Gets the git repository projects.
      Parameters:
      user - the user
      workspace - the workspace
      repositoryName - the repository name
      Returns:
      the git repository projects
    • getGitRepositoryProjectsFiles

      public static List<File> getGitRepositoryProjectsFiles​(String user, String workspace, String repositoryName)
      Gets the git repository projects files.
      Parameters:
      user - the user
      workspace - the workspace
      repositoryName - the repository name
      Returns:
      the git repository projects files
    • getGitRepositoryProjects

      public static List<File> getGitRepositoryProjects​(File gitRepository)
      Gets the git repository projects.
      Parameters:
      gitRepository - the git repository
      Returns:
      the git repository projects
    • find

      public static final List<String> find​(String root, String pattern) throws IOException
      Find.
      Parameters:
      root - the root
      pattern - the pattern
      Returns:
      the list
      Throws:
      IOException - Signals that an I/O exception has occurred.