Hi,
I'm using VFS in a small homegrown CMS project to copy whole folder trees
about in a platform independant way.
Here's some code with "CMSMount", "destDir", and "src" all strings
containing system paths.
FileSystemManager fsm = VFS.getManager();
File destDir = new File(CMSMount+"/"+target);
if (destDir.exists()) {
File file = new File(CMSMount+"/"+src);
if (!file.exists()) {
throw new EventHandlerException("source "+src+" not
found");
} else {
Logger.debugLog("copying "+ file.getAbsolutePath());
FileObject srcObj = fsm.toFileObject(file);
FileObject targetObj =
fsm.resolveFile(CMSMount+"/"+target);
Logger.debugLog("src object:
"+srcObj.getURL().toString());
targetObj.copyFrom(srcObj, new AllFileSelector());
targetObj.close();
srcObj.close();
}
}
This code works fine when the system is started up and after you have
changed existing files in the source folder.
However, if you add a new file to the filesystem seperately and then run
the above code it fails with:
org.apache.commons.vfs.FileSystemException: Could not copy
"file:///path/to/source/filename.html" to
"file:///path/to/target/filename.html"
I assume that this is because the vfs system keeps the filestructure in
memory and cannot cope with new files being added.
Is there anyway to refresh the FileSystemManager object?
Brendan Richards
Senior Developer
Draft London
0207 894 5167
LEGAL NOTICE:This e-mail has been sent to you by Draft London. This
communication, and the information it contains, is intended for the
person(s) or organisation(s) to whom it is addressed. Its contents are
confidential and may be protected in law. Unauthorised use, copying or
disclosure of any of it may be unlawful. If you are not the intended
recipient, please notify the sender by replying with 'Received in error'
as the subject and then delete it from your mailbox. Any views or opinions
presented are solely those of the author and do not necessarily represent
those of Draft London. Although this e-mail and any attachments are
believed to be free of any virus or other defects which might affect any
computer or IT system into which they are received, no responsibility is
accepted from Draft London or any of its associated companies for any loss
or damage arising in any way from the receipt or use thereof. We recommend
that you should carry out your own virus checking procedure before opening
any attachment.