Class FileSystemUtils
java.lang.Object
org.eclipse.dirigible.commons.api.helpers.FileSystemUtils
public class FileSystemUtils extends Object
The File System Utils.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description FileSystemUtils() -
Method Summary
Modifier and Type Method Description static voidcopyFile(String srcPath, String destPath)Copy file.static voidcopyFolder(String srcPath, String destPath)Copy folder.static booleancreateFile(String workspacePath)Creates the file.static booleancreateFolder(String workspacePath)Creates the folder.static voidcreateFoldersIfNecessary(String workspacePath)Creates the folders if necessary.static booleandirectoryExists(String location)Directory exists.static booleanexists(String location)Exists.static booleanfileExists(String location)File exists.static List<String>find(String root, String pattern)static FileforceCreateDirectory(String firstSegment, String... segments)Force create directory and all its parentsstatic StringgenerateGitRepositoryName(String repositoryURI)Generate the local repository namestatic FilegetDirectory(String firstSegment, String... segments)Returns the directory by segmentsstatic StringgetExtension(String workspacePath)Gets the extension.static FilegetGitDirectory(String user, String workspace)Get the directory for gitstatic FilegetGitDirectory(String user, String workspace, String repositoryURI)Get the directory for gitstatic FilegetGitDirectoryByRepositoryName(String user, String workspace, String repositoryName)Get the directory for gitstatic List<String>getGitRepositories(String user, String workspace)static List<String>getGitRepositoryProjects(String user, String workspace, String repositoryName)static DategetModifiedAt(String workspacePath)Gets the modified at.static StringgetOwner(String workspacePath)Gets the owner.static booleanisDirectory(String location)Checks if is directory.static File[]listFiles(File directory)List files including symbolic linksstatic byte[]loadFile(String workspacePath)Load file.static voidmoveFile(String workspacePathOld, String workspacePathNew)Move file.static voidremoveFile(String workspacePath)Removes the file.static voidsaveFile(String workspacePath, byte[] content)Save file.
-
Field Details
-
DOT_GIT
- See Also:
- Constant Field Values
-
-
Constructor Details
-
FileSystemUtils
public FileSystemUtils()
-
-
Method Details
-
saveFile
public static void saveFile(String workspacePath, byte[] content) throws FileNotFoundException, IOExceptionSave file.- Parameters:
workspacePath- the workspace pathcontent- the content- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
loadFile
Load file.- Parameters:
workspacePath- the workspace path- Returns:
- the byte[]
- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
moveFile
public static void moveFile(String workspacePathOld, String workspacePathNew) throws FileNotFoundException, IOExceptionMove file.- Parameters:
workspacePathOld- the workspace path oldworkspacePathNew- the workspace path new- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
copyFile
public static void copyFile(String srcPath, String destPath) throws FileNotFoundException, IOExceptionCopy file.- Parameters:
srcPath- the src pathdestPath- the dest path- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
copyFolder
public static void copyFolder(String srcPath, String destPath) throws FileNotFoundException, IOExceptionCopy folder.- Parameters:
srcPath- the src pathdestPath- the dest path- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
removeFile
Removes the file.- Parameters:
workspacePath- the workspace path- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
createFolder
Creates the folder.- Parameters:
workspacePath- the workspace path- Returns:
- true, if successful
-
createFile
Creates the file.- Parameters:
workspacePath- the workspace path- Returns:
- true, if successful
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getExtension
Gets the extension.- Parameters:
workspacePath- the workspace path- Returns:
- the extension
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getOwner
Gets the owner.- Parameters:
workspacePath- the workspace path- Returns:
- the owner
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getModifiedAt
Gets the modified at.- Parameters:
workspacePath- the workspace path- Returns:
- the modified at
- Throws:
IOException- Signals that an I/O exception has occurred.
-
createFoldersIfNecessary
Creates the folders if necessary.- Parameters:
workspacePath- the workspace path
-
exists
Exists.- Parameters:
location- the location- Returns:
- true, if successful
-
directoryExists
Directory exists.- Parameters:
location- the location- Returns:
- true, if successful
-
fileExists
File exists.- Parameters:
location- the location- Returns:
- true, if successful
-
isDirectory
Checks if is directory.- Parameters:
location- the location- Returns:
- true, if is directory
-
listFiles
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 IOExceptionForce create directory and all its parents- Parameters:
firstSegment- the first segmentsegments- the rest segments- Returns:
- the resulting path
- Throws:
IOException- IO error
-
getDirectory
Returns the directory by segments- Parameters:
firstSegment- the first segmentsegments- the rest segments- Returns:
- the resulting path
-
generateGitRepositoryName
Generate the local repository name- Parameters:
repositoryURI- the URI odf the repository- Returns:
- the generated local name
-
getGitDirectory
Get the directory for git- Parameters:
user- logged-in userworkspace- the workspace- Returns:
- the directory
-
getGitRepositories
-
getGitDirectory
Get the directory for git- Parameters:
user- logged-in userworkspace- the workspacerepositoryURI- 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 userworkspace- the workspacerepositoryName- the repository URI- Returns:
- the directory
-
getGitRepositoryProjects
-
find
- Throws:
IOException
-