com.continuent.tungsten.common.commands
Class DirectoryCommands

java.lang.Object
  extended by com.continuent.tungsten.common.commands.DirectoryCommands

public class DirectoryCommands
extends java.lang.Object

Commands to assist in directory manipulation

Version:
1.0
Author:
Joe Daly

Constructor Summary
DirectoryCommands()
           
 
Method Summary
static void copyFile(java.lang.String srcPath, java.lang.String destPath)
          Copy a file on the local filesystem
static boolean deleteDirectory(java.lang.String path)
          Removes the given directory and any sub directories.
static boolean deleteFile(java.lang.String filePath)
          Deletes a file
static boolean deleteFiles(java.lang.String directoryPath)
          Deletes files in a directory matching a specific pattern
static boolean exists(java.lang.String path)
          Checks if the path given exists.
static java.util.List<java.lang.String> fileList(java.lang.String directoryPath, boolean includeFullPath)
          Returns a listing of files in a directory matching a pattern.
static boolean isDirectory(java.lang.String path)
          Checks if the given path is a directory
static boolean isFile(java.lang.String path)
          Checks if the given path is a file
static boolean mkdir(java.lang.String path)
          Creates a directory
static boolean mkdirs(java.lang.String path)
          Creates a directory and any subdirectories
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectoryCommands

public DirectoryCommands()
Method Detail

isDirectory

public static boolean isDirectory(java.lang.String path)
Checks if the given path is a directory

Parameters:
path - the path to check if its a directory
Returns:
true if the path is a directory

isFile

public static boolean isFile(java.lang.String path)
Checks if the given path is a file

Parameters:
path - the path to check if its a file
Returns:
true if the given path is a file

exists

public static boolean exists(java.lang.String path)
Checks if the path given exists. No distinction is made between a file or directory

Parameters:
path - the path to check
Returns:
true if a file or directry exists

mkdir

public static boolean mkdir(java.lang.String path)
Creates a directory

Parameters:
path - the path to create
Returns:
true if the directory was created

mkdirs

public static boolean mkdirs(java.lang.String path)
Creates a directory and any subdirectories

Parameters:
path - the path to create, will also create any subdirectories
Returns:
true if the directory was created

deleteDirectory

public static boolean deleteDirectory(java.lang.String path)
Removes the given directory and any sub directories. This is equivalent on unix to running rm -rf.

Parameters:
path - remove this directory and any sub directories
Returns:
true if the directory no longer exists

deleteFiles

public static boolean deleteFiles(java.lang.String directoryPath)
Deletes files in a directory matching a specific pattern

Parameters:
directoryPath - the directory to delete files in

deleteFile

public static boolean deleteFile(java.lang.String filePath)
Deletes a file

Parameters:
filePath - the file to delete
Returns:
true if the file is deleted

fileList

public static java.util.List<java.lang.String> fileList(java.lang.String directoryPath,
                                                        boolean includeFullPath)
Returns a listing of files in a directory matching a pattern.

Parameters:
directoryPath - the directory to get a file listing of; listingPattern the pattern to search for in the file listing
Returns:
the contents of the directory that match the pattern

copyFile

public static void copyFile(java.lang.String srcPath,
                            java.lang.String destPath)
                     throws java.lang.Exception
Copy a file on the local filesystem

Parameters:
srcPath - the source file
destPath - where the file should be copied to
Throws:
java.lang.Exception - if there was a problem copying the file