public final class HardlinkCopyDirectoryWrapper extends FilterDirectory
Directory.copyFrom(Directory, String, String, IOContext)
in order
to optionally use a hard-link instead of a full byte by byte file copy if applicable. Hard-links are only used if the
underlying filesystem supports it and if the LinkPermission
"hard" is granted.
NOTE: Using hard-links changes the copy semantics of
Directory.copyFrom(Directory, String, String, IOContext)
. When hard-links are used changes to the source file
will be reflected in the target file and vice-versa. Within Lucene, files are write once and should not be modified
after they have been written. This directory should not be used in situations where files change after they have
been written.
in
Constructor and Description |
---|
HardlinkCopyDirectoryWrapper(Directory in)
Creates a new HardlinkCopyDirectoryWrapper delegating to the given directory
|
Modifier and Type | Method and Description |
---|---|
void |
copyFrom(Directory from,
java.lang.String srcFile,
java.lang.String destFile,
IOContext context)
Copies the file src in from to this directory under the new
file name dest.
|
close, createOutput, createTempOutput, deleteFile, fileLength, getDelegate, listAll, obtainLock, openInput, rename, sync, syncMetaData, toString, unwrap
ensureOpen, openChecksumInput
public HardlinkCopyDirectoryWrapper(Directory in)
public void copyFrom(Directory from, java.lang.String srcFile, java.lang.String destFile, IOContext context) throws java.io.IOException
Directory
If you want to copy the entire source directory to the destination one, you can do so like this:
Directory to; // the directory to copy to for (String file : dir.listAll()) { to.copyFrom(dir, file, newFile, IOContext.DEFAULT); // newFile can be either file, or a new name }
NOTE: this method does not check whether dest exist and will overwrite it if it does.
Copyright © 2000–2018 The Apache Software Foundation. All rights reserved.