public abstract class FileSystem extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
FileSystem.ForLegacyVm
A file system representation for a VM that does not support NIO2.
|
protected static class |
FileSystem.ForNio2CapableVm
A file system representation for a VM that does support NIO2.
|
| Constructor and Description |
|---|
FileSystem() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
copy(File source,
File target)
Copies a file.
|
static FileSystem |
getInstance()
Returns the
FileSystem instance to use. |
void |
link(File source,
File target)
Links a file as a hard-link.
|
abstract void |
move(File source,
File target)
Moves a file.
|
static File |
validated(File folder,
File target)
Validates that a target file is contained within a folder once both paths are canonicalized.
|
static String |
validated(String name)
Validates that a
/-separated entry name does not escape the root directory it is resolved against
when it is written to a folder or extracted from an archive. |
@CachedReturnPlugin.Enhance(value="INSTANCE") public static FileSystem getInstance()
FileSystem instance to use.FileSystem instance to use.public static String validated(String name)
/-separated entry name does not escape the root directory it is resolved against
when it is written to a folder or extracted from an archive. This guards against a path traversal from a
type name that contains traversal segments, for example from a crafted this_class constant pool entry.name - The entry name to validate, using / as a separator.public static File validated(File folder, File target) throws IOException
folder - The folder that the target file must be contained within.target - The target file to validate.IOException - If the canonical path of either file cannot be resolved.public abstract void copy(File source, File target) throws IOException
source - The source file.target - The target file.IOException - If an I/O exception occurs.public void link(File source, File target) throws IOException
source - The source file.target - The target file.IOException - If an I/O exception occurs.public abstract void move(File source, File target) throws IOException
source - The source file.target - The target file.IOException - If an I/O exception occurs.Copyright © 2014–2026. All rights reserved.