Class FilteringUtils
java.lang.Object
org.apache.maven.shared.filtering.FilteringUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
buildRelativePath
(String toPath, String fromPath, char separatorChar) private static Charset
static void
copyFile
(File from, File to, String encoding, FilterWrapper[] wrappers, boolean overwrite) If wrappers is null or empty, the file will be copy only if to.lastModified() < from.lastModified() or if overwrite is trueprivate static void
copyFilePermissions
(File source, File destination) Attempts to copy file permissions from the source to the destination file.static String
escapeWindowsPath
(String val) static String
getRelativeFilePath
(String oldPath, String newPath) This method can calculate the relative path between two paths on a file system.(package private) static boolean
static File
resolveFile
(File baseFile, String filename) Resolve a filefilename
to its canonical form.
-
Field Details
-
ONE_KB
private static final int ONE_KBThe number of bytes in a kilobyte.- See Also:
-
ONE_MB
private static final int ONE_MBThe number of bytes in a megabyte.- See Also:
-
FILE_COPY_BUFFER_SIZE
private static final int FILE_COPY_BUFFER_SIZEThe file copy buffer size (30 MB)- See Also:
-
WINDOWS_PATH_PATTERN
- See Also:
-
PATTERN
-
-
Constructor Details
-
FilteringUtils
private FilteringUtils()
-
-
Method Details
-
escapeWindowsPath
- Parameters:
val
- The value to be escaped.- Returns:
- Escaped value
-
resolveFile
Resolve a filefilename
to its canonical form. Iffilename
is relative (doesn't start with/
), it is resolved relative tobaseFile
. Otherwise it is treated as a normal root-relative path.- Parameters:
baseFile
- where to resolvefilename
from, iffilename
is relativefilename
- absolute or relative file path to resolve- Returns:
- the canonical
File
offilename
-
getRelativeFilePath
This method can calculate the relative path between two paths on a file system.
PathTool.getRelativeFilePath( null, null ) = "" PathTool.getRelativeFilePath( null, "/usr/local/java/bin" ) = "" PathTool.getRelativeFilePath( "/usr/local", null ) = "" PathTool.getRelativeFilePath( "/usr/local", "/usr/local/java/bin" ) = "java/bin" PathTool.getRelativeFilePath( "/usr/local", "/usr/local/java/bin/" ) = "java/bin" PathTool.getRelativeFilePath( "/usr/local/java/bin", "/usr/local/" ) = "../.." PathTool.getRelativeFilePath( "/usr/local/", "/usr/local/java/bin/java.sh" ) = "java/bin/java.sh" PathTool.getRelativeFilePath( "/usr/local/java/bin/java.sh", "/usr/local/" ) = "../../.." PathTool.getRelativeFilePath( "/usr/local/", "/bin" ) = "../../bin" PathTool.getRelativeFilePath( "/bin", "/usr/local/" ) = "../usr/local"
Note: On Windows based system, the/
character should be replaced by\
character.- Parameters:
oldPath
- old pathnewPath
- new path- Returns:
- a relative file path from
oldPath
.
-
buildRelativePath
-
isEmpty
-
copyFilePermissions
Attempts to copy file permissions from the source to the destination file. Initially attempts to copy posix file permissions, assuming that the files are both on posix filesystems. If the initial attempts fail then a second attempt using less precise permissions model. Note that permissions are copied on a best-efforts basis, failure to copy permissions will not result in an exception.- Parameters:
source
- the file to copy permissions from.destination
- the file to copy permissions to.- Throws:
IOException
-
charset
-