Class CUtil
java.lang.Object
net.sf.antcontrib.cpptasks.CUtil
Some utilities used by the CC and Link tasks.
- Author:
- Adam Murdoch, Curt Arnold
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA class that splits a white-space, comma-separated list into a String array. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds the elements of the array to the given vectorstatic intcheckDirectoryArray(String[] names) Checks a array of names for non existent or non directory entries and nulls them out.static StringgetBasename(File file) Extracts the basename of a file, removing the extension, if presentstatic FilegetExecutableLocation(String exeName) Gets the parent directory for the executable file name using the current directory and system executable pathstatic StringgetParentPath(String path) Extracts the parent of a filestatic File[]getPathFromEnvironment(String envVariable, String delim) Returns an array of File for each existing directory in the specified environment variablestatic StringgetRelativePath(String base, File targetFile) Returns a relative path for the targetFile relative to the base directory.static booleanstatic booleanisSignificantlyAfter(long time1, long time2) Determines whether time1 is later than time2 to a degree that file system time truncation is not significant.static booleanisSignificantlyBefore(long time1, long time2) Determines whether time1 is earlier than time2 to a degree that file system time truncation is not significant.static booleanisSystemPath(File source) Determines if source file has a system path, that is part of the compiler or platform.static File[]Parse a string containing directories into an File[]static intrunCommand(CCTask task, File workingDir, String[] cmdline, boolean newEnvironment, org.apache.tools.ant.types.Environment env) This method is exposed so test classes can overload and test the arguments without actually spawning the compilerstatic booleanCompares the contents of 2 arrays for equaliy.static booleanCompares the contents of an array and a Vector for equality.static booleanCompares the contents of an array and a Vector for set equality.static String[]Converts a vector to a string array.static StringtoUnixPath(String path) static StringtoWindowsPath(String path) static StringxmlAttribEncode(String attrValue) Replaces any embedded quotes in the string so that the value can be placed in an attribute in an XML file
-
Field Details
-
FILETIME_EPSILON
public static final int FILETIME_EPSILON- See Also:
-
-
Constructor Details
-
CUtil
public CUtil()
-
-
Method Details
-
addAll
-
checkDirectoryArray
Checks a array of names for non existent or non directory entries and nulls them out.- Returns:
- Count of non-null elements
-
getBasename
-
getExecutableLocation
-
getParentPath
-
getPathFromEnvironment
Returns an array of File for each existing directory in the specified environment variable- Parameters:
envVariable- environment variable name such as "LIB" or "INCLUDE"delim- delimitor used to separate parts of the path, typically ";" or ":"- Returns:
- array of File's for each part that is an existing directory
-
getRelativePath
Returns a relative path for the targetFile relative to the base directory.- Parameters:
base- base directory as returned by File.getCanonicalPath()targetFile- target file- Returns:
- relative path of target file. Returns targetFile if there were no commonalities between the base and the target
-
isActive
-
parsePath
-
runCommand
public static int runCommand(CCTask task, File workingDir, String[] cmdline, boolean newEnvironment, org.apache.tools.ant.types.Environment env) throws org.apache.tools.ant.BuildException This method is exposed so test classes can overload and test the arguments without actually spawning the compiler- Throws:
org.apache.tools.ant.BuildException
-
sameList
-
sameList
-
sameSet
-
toArray
-
xmlAttribEncode
-
isSignificantlyBefore
public static boolean isSignificantlyBefore(long time1, long time2) Determines whether time1 is earlier than time2 to a degree that file system time truncation is not significant.- Parameters:
time1- long first time valuetime2- long second time value- Returns:
- boolean if first time value is earlier than second time value. If the values are within the rounding error of the file system return false.
-
isSignificantlyAfter
public static boolean isSignificantlyAfter(long time1, long time2) Determines whether time1 is later than time2 to a degree that file system time truncation is not significant.- Parameters:
time1- long first time valuetime2- long second time value- Returns:
- boolean if first time value is later than second time value. If the values are within the rounding error of the file system return false.
-
toWindowsPath
-
toUnixPath
-
isSystemPath
Determines if source file has a system path, that is part of the compiler or platform.- Parameters:
source- source, may not be null.- Returns:
- true is source file appears to be system library and its path should be discarded.
-