Class RenameUtil
- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- ch.qos.logback.core.rolling.helper.RenameUtil
-
- All Implemented Interfaces:
ContextAware
public class RenameUtil extends ContextAwareBase
Utility class to help solving problems encountered while renaming files.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.String
RENAMING_ERROR_URL
-
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
-
Constructor Summary
Constructors Constructor Description RenameUtil()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.lang.Boolean
areOnDifferentVolumes(java.io.File srcFile, java.io.File targetFile)
Attempts to determine whether both files are on different volumes.(package private) void
createMissingTargetDirsIfNecessary(java.io.File toFile)
void
rename(java.lang.String src, java.lang.String target)
A relatively robust file renaming method which in case of failure due to src and target being on different volumes, falls back onto renaming by copying.void
renameByCopying(java.lang.String src, java.lang.String target)
java.lang.String
toString()
-
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
-
-
-
Method Detail
-
rename
public void rename(java.lang.String src, java.lang.String target) throws RolloverFailure
A relatively robust file renaming method which in case of failure due to src and target being on different volumes, falls back onto renaming by copying.- Parameters:
src
-target
-- Throws:
RolloverFailure
-
areOnDifferentVolumes
java.lang.Boolean areOnDifferentVolumes(java.io.File srcFile, java.io.File targetFile) throws RolloverFailure
Attempts to determine whether both files are on different volumes. Returns true if we could determine that the files are on different volumes. Returns false otherwise or if an error occurred while doing the check.- Parameters:
srcFile
-targetFile
-- Returns:
- true if on different volumes, false otherwise or if an error occurred
- Throws:
RolloverFailure
-
renameByCopying
public void renameByCopying(java.lang.String src, java.lang.String target) throws RolloverFailure
- Throws:
RolloverFailure
-
createMissingTargetDirsIfNecessary
void createMissingTargetDirsIfNecessary(java.io.File toFile) throws RolloverFailure
- Throws:
RolloverFailure
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-