1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs2.impl;
18
19 import org.apache.commons.vfs2.FileName;
20 import org.apache.commons.vfs2.FileObject;
21 import org.apache.commons.vfs2.FileSystem;
22 import org.apache.commons.vfs2.FileSystemException;
23 import org.apache.commons.vfs2.FileType;
24 import org.apache.commons.vfs2.provider.AbstractFileName;
25 import org.apache.commons.vfs2.provider.AbstractFileSystem;
26 import org.apache.commons.vfs2.provider.AbstractVfsContainer;
27
28
29
30
31 public class VirtualFileProvider extends AbstractVfsContainer {
32
33
34
35
36
37
38
39
40 public FileObject#FileObject">FileObject createFileSystem(final FileObject rootFile) throws FileSystemException {
41 final AbstractFileName../org/apache/commons/vfs2/provider/AbstractFileName.html#AbstractFileName">AbstractFileName rootName = (AbstractFileName) getContext().getFileSystemManager()
42 .resolveName(rootFile.getName(), FileName.ROOT_PATH);
43 final VirtualFileSystemtualFileSystem.html#VirtualFileSystem">VirtualFileSystem fs = new VirtualFileSystem(rootName, rootFile.getFileSystem().getFileSystemOptions());
44 addComponent(fs);
45 fs.addJunction(FileName.ROOT_PATH, rootFile);
46 return fs.getRoot();
47 }
48
49
50
51
52
53
54
55
56 public FileObject createFileSystem(final String rootUri) throws FileSystemException {
57 final AbstractFileName rootName = new VirtualFileName(rootUri, FileName.ROOT_PATH, FileType.FOLDER);
58 final VirtualFileSystemtualFileSystem.html#VirtualFileSystem">VirtualFileSystem fs = new VirtualFileSystem(rootName, null);
59 addComponent(fs);
60 return fs.getRoot();
61 }
62
63
64
65
66
67
68
69
70
71 void closeFileSystem(final FileSystem fileSystem) {
72 final AbstractFileSystem/../../org/apache/commons/vfs2/provider/AbstractFileSystem.html#AbstractFileSystem">AbstractFileSystem fs = (AbstractFileSystem) fileSystem;
73
74 removeComponent(fs);
75 fs.close();
76 }
77 }