Currently, I have them working on my system (Mac OSX) but I have yet to implement a GUI interface for adding/editing them. So at the moment, they must be manual written to the PMS.conf
To give you an idea of how I implemented them, here are a few code snippets: (Note: They are a little quick and dirty atm and need more error checking)
The virtual folders are stored (in the config file) using the syntax:
vfoldername:/path/to/folder1,/path/to/folder2; (Note: these paths are escaped in the real config file, ie \/path\/to\/folder)
This method reads them in: (Based largely off of the loadFolderConf method)
- Code: Select all
public VirtualFolder [] loadVirtualFoldersConf(String vfolders) throws IOException {
if (vfolders == null || vfolders.length() == 0)
return null;
ArrayList<VirtualFolder> directories = new ArrayList<VirtualFolder>();
VirtualFolder vf;
StringTokenizer st = new StringTokenizer(vfolders, ";"); //$NON-NLS-1$
while (st.hasMoreTokens()) {
String line = st.nextToken();
String[] vfolder = line.split(":");
if (vfolder.length == 2) {
vf = new VirtualFolder(vfolder[0],null);
}
else {
PMS.error("Error Parsing Virtual Folders", null);
continue;
}
StringTokenizer stF = new StringTokenizer(vfolder[1], ",");
while (stF.hasMoreTokens()) {
String path = stF.nextToken();
File file = new File(path);
if (file.exists()) {
if (file.isDirectory()) {
File files [] = file.listFiles();
for(File f:files) {
vf.addChild(new RealFile(f));
}
} else
PMS.error("File " + path + " is not a directory!", null);
} else {
PMS.error("File " + path + " does not exists!", null);
}
}
directories.add(vf);
}
VirtualFolder f [] = new VirtualFolder[directories.size()];
for(int j=0;j<f.length;j++)
f[j] = directories.get(j);
return f;
}
This code works pretty well but has some thumbnail issues i need to look into.
This is code I added to manageRoot so that the virtual folders are loaded alongside the regular ones:
- Code: Select all
VirtualFolder vfs [] = loadVirtualFoldersConf(configuration.getVirtualFolders());
if (files == null || files.length == 0) {
}
else {
for(VirtualFolder vf:vfs) {
getRootFolder(renderer).addChild(vf);
}
}
I would be happy to add the GUI part and finish it if the devs want to include this.
