org.kuali.common.util
Class FileSystemUtils

java.lang.Object
  extended by org.kuali.common.util.FileSystemUtils

public class FileSystemUtils
extends Object


Field Summary
static List<String> DEFAULT_RECURSIVE_INCLUDES
           
static List<String> DEFAULT_SCM_IGNORE_PATTERNS
           
static String RECURSIVE_FILE_INCLUDE_PATTERN
           
 
Constructor Summary
FileSystemUtils()
           
 
Method Summary
static CopyFileResult copyFile(File src, File dst)
           
protected static void copyFiles(File srcDir, List<File> files, File dstDir)
           
static List<CopyFileResult> copyFiles(List<CopyFileRequest> requests)
           
protected static void fillInMD5Results(DirDiff diff)
           
static List<File> getAllNonScmFiles(File dir)
          Return a recursive listing of all files in the directory ignoring ++/.svn/++ and ++/.git/++
static List<File> getAllNonScmFiles(File dir, List<String> scmIgnorePatterns)
          Return a recursive listing of all files in the directory ignoring files that match scmIgnorePatterns
static List<CopyFileRequest> getCopyFileRequests(File srcDir, List<String> includes, List<String> excludes, File dstDir)
           
static DirectoryDiff getDiff(DirectoryDiffRequest request)
          Deprecated. 
static DirectoryDiff getDiff(File dir1, File dir2, List<String> includes, List<String> excludes)
          Deprecated. 
static List<File> getFiles(File dir, List<String> includes, List<String> excludes)
           
static List<File> getFullPaths(File dir, List<String> relativePaths)
           
static List<File> getFullPaths(File dir, Set<String> relativePaths)
           
static DirDiff getMD5Diff(DirRequest request)
          Compare 2 directories on the file system and return an object containing the results.
static MD5Result getMD5Result(File source, File target)
           
static List<MD5Result> getMD5Results(List<File> sources, List<File> targets)
           
static DirDiff getQuickDiff(DirRequest request)
           
static String getRelativePath(File dir, File file)
           
static String getRelativePathQuietly(File parentDir, File file)
          Return the relative path to file from parentDir.
protected static List<String> getRelativePaths(File dir, List<File> files)
           
static List<File> getSortedFullPaths(File dir, List<String> relativePaths)
           
static boolean isParent(File parent, File child)
          Return true if child lives on the file system somewhere underneath parent, false otherwise.
static MonitorTextFileResult monitorTextFile(File file, String token, int intervalMillis, int timeoutMillis, String encoding)
          Examine the contents of a text file, stopping as soon as it contains token, or timeout is exceeded, whichever comes first.
static DirectoryDiff prepareScmDir(PrepareScmDirRequest request)
          Deprecated. 
static DirectoryDiff prepareScmDir(PrepareScmDirRequest request, File relativeDir, boolean diffOnly)
          Deprecated.  
static List<SyncResult> syncFiles(List<SyncRequest> requests)
           
static SyncResult syncFiles(SyncRequest request)
           
static SyncResult syncFilesQuietly(SyncRequest request)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RECURSIVE_FILE_INCLUDE_PATTERN

public static final String RECURSIVE_FILE_INCLUDE_PATTERN
See Also:
Constant Field Values

DEFAULT_RECURSIVE_INCLUDES

public static final List<String> DEFAULT_RECURSIVE_INCLUDES

DEFAULT_SCM_IGNORE_PATTERNS

public static final List<String> DEFAULT_SCM_IGNORE_PATTERNS
Constructor Detail

FileSystemUtils

public FileSystemUtils()
Method Detail

getAllNonScmFiles

public static List<File> getAllNonScmFiles(File dir)
Return a recursive listing of all files in the directory ignoring ++/.svn/++ and ++/.git/++


getAllNonScmFiles

public static List<File> getAllNonScmFiles(File dir,
                                           List<String> scmIgnorePatterns)
Return a recursive listing of all files in the directory ignoring files that match scmIgnorePatterns


prepareScmDir

@Deprecated
public static DirectoryDiff prepareScmDir(PrepareScmDirRequest request)
Deprecated. 

This method recursively copies one file system directory to another directory under the control of SCM. Before doing so, it records 3 types of files:
  1 - both     - files that exist in both directories 
  2 - dir1Only - files that exist in the source directory but not the SCM directory
  3 - dir2Only - files that exist in the SCM directory but not the source directory
 
This provides enough information for SCM tooling to then complete the work of making the SCM directory exactly match the file system directory and commit any changes to the SCM system.


prepareScmDir

@Deprecated
public static DirectoryDiff prepareScmDir(PrepareScmDirRequest request,
                                                     File relativeDir,
                                                     boolean diffOnly)
Deprecated. 

This method recursively copies one file system directory to another directory under the control of SCM. Before doing so, it records 3 types of files:
  1 - both     - files that exist in both directories 
  2 - dir1Only - files that exist in the source directory but not the SCM directory
  3 - dir2Only - files that exist in the SCM directory but not the source directory
 
This provides enough information for SCM tooling to then complete the work of making the SCM directory exactly match the file system directory and commit any changes to the SCM system.


getFiles

public static List<File> getFiles(File dir,
                                  List<String> includes,
                                  List<String> excludes)

getDiff

@Deprecated
public static DirectoryDiff getDiff(File dir1,
                                               File dir2,
                                               List<String> includes,
                                               List<String> excludes)
Deprecated. 


getMD5Diff

public static DirDiff getMD5Diff(DirRequest request)
Compare 2 directories on the file system and return an object containing the results. All of the files contained in either of the 2 directories get aggregated into 5 categories.
 1 - Both            - Files that exist in both directories
 2 - Different       - Files that exist in both directories but who's MD5 checksums do not match 
 3 - Identical       - Files that exist in both directories with matching MD5 checksums 
 4 - Source Dir Only - Files that exist only in the source directory
 5 - Target Dir Only - Files that exist only in the target directory
 
The 5 lists in DirDiff contain the relative paths to files for each category.


getMD5Results

public static List<MD5Result> getMD5Results(List<File> sources,
                                            List<File> targets)

fillInMD5Results

protected static void fillInMD5Results(DirDiff diff)

getMD5Result

public static MD5Result getMD5Result(File source,
                                     File target)

getDiff

@Deprecated
public static DirectoryDiff getDiff(DirectoryDiffRequest request)
Deprecated. 

Compare 2 directories on the file system and return an object containing the results. All of the files contained in either of the 2 directories get placed into one of 3 categories.
 1 - Both       - Files that exist in both directories
 2 - Dir 1 Only - Files that exist only in directory 1
 3 - Dir 2 Only - Files that exist only in directory 2
 
The 3 lists in DirectoryDiff contain the relative paths to files for each category.


getQuickDiff

public static DirDiff getQuickDiff(DirRequest request)

monitorTextFile

public static MonitorTextFileResult monitorTextFile(File file,
                                                    String token,
                                                    int intervalMillis,
                                                    int timeoutMillis,
                                                    String encoding)
Examine the contents of a text file, stopping as soon as it contains token, or timeout is exceeded, whichever comes first.


syncFiles

public static List<SyncResult> syncFiles(List<SyncRequest> requests)
                                  throws IOException
Throws:
IOException

syncFilesQuietly

public static SyncResult syncFilesQuietly(SyncRequest request)

syncFiles

public static SyncResult syncFiles(SyncRequest request)
                            throws IOException
Throws:
IOException

copyFiles

protected static void copyFiles(File srcDir,
                                List<File> files,
                                File dstDir)
                         throws IOException
Throws:
IOException

getFullPaths

public static List<File> getFullPaths(File dir,
                                      Set<String> relativePaths)

getSortedFullPaths

public static List<File> getSortedFullPaths(File dir,
                                            List<String> relativePaths)

getFullPaths

public static List<File> getFullPaths(File dir,
                                      List<String> relativePaths)

getRelativePaths

protected static List<String> getRelativePaths(File dir,
                                               List<File> files)

isParent

public static boolean isParent(File parent,
                               File child)
Return true if child lives on the file system somewhere underneath parent, false otherwise.


getRelativePathQuietly

public static String getRelativePathQuietly(File parentDir,
                                            File file)
Return the relative path to file from parentDir. parentDir is optional and can be null. If parentDir is not supplied (or is not a parent directory to file the canonical path to file is returned.


getRelativePath

public static String getRelativePath(File dir,
                                     File file)

getCopyFileRequests

public static List<CopyFileRequest> getCopyFileRequests(File srcDir,
                                                        List<String> includes,
                                                        List<String> excludes,
                                                        File dstDir)

copyFile

public static CopyFileResult copyFile(File src,
                                      File dst)

copyFiles

public static List<CopyFileResult> copyFiles(List<CopyFileRequest> requests)


Copyright © 2010-2013 The Kuali Foundation. All Rights Reserved.