Warning: session_start(): open(/var/lib/php/sessions/sess_meshfnibkhmdkr0ep52ig45fnh, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
sclass DirectoryInfo extends DynModule {
S dir;
bool allowedToLook;
Bool exists, isFile;
L filesContained; // this should be an immutable list b/c of listeners
transient JComboBox comboBox;
File dirObject() { ret newFile(dir); }
void start {
ownTimer(doEvery(2.0, r fullUpdate)); // TODO: watch service
}
JComponent visualize() {
if (dir == null)
ret jcenteredbutton("Select directory...", r {
selectFile("Select directory to show", voidfunc(File dir) {
setField(dir := f2s(dir));
revisualize();
});
});
if (comboBox == null)
comboBox = yesNoComboBox(allowedToLook,
voidfunc(bool b) { setField(allowedToLook := b) });
ret makeForm(
"Directory" := dir,
allowedToLook := comboBox,
+exists,
+isFile,
"Files contained", filesContained == null ? "Unknown" : l(filesContained));
}
void fullUpdate { lock lock; filesContained = null; update(); }
void update {
lock lock;
if (dir != null && allowedToLook) {
File dirObject = dirObject();
setField(exists := dirObject.isDirectory());
setField(isFile := dirObject.isFile());
if (filesContained == null
&& setField(filesContained := listFileNames(dirObject)))
revisualize();
} else
if (setFields(exists := null, isFile := null, filesContained := null)) revisualize();
}
// API for other modules
S getDir() { ret dir; }
L getFiles() { ret filesContained; }
}