!759 concepts. concept MayReadFile { S path; long length; } // = may read this directory and all files directly in it concept MayReadDir { S path; } // First bytes of a file concept FirstBytes { new Ref file; byte[] data; } p { loadAndAutoSaveConcepts(); makeBot(); } static MayReadFile mayReadFile(File f) { ret uniq(MayReadFile, "path", f.getPath(), "length", f.length()); } synchronized answer { if "you may read *" { S path = m.unq(0); File f = new File(path); if (!f.isAbsolute()) ret "Need absolute path"; if (!f.exists()) ret "Not found: " + path; if (f.isDirectory()) { uniq(MayReadDir, +path); ret "Directory " + quote(path) + " marked as readable"; } else { mayReadFile(f); ret "File " + quote(path) + " marked as readable"; } } if "read dirs" { for (MayReadDir dir) { for (File f : listFilesOnly(dir.path)) mayReadFile(f); } ret "OK, now " + n(countConcepts(MayReadFile), "readable files"); } if "read * first bytes" { int n = parseInt(m.unq(0)); for (MayReadFile file) pcall { cset(uniq(FirstBytes, +file), "data", loadFirstBytes(file.path, n)); } ret "OK, now have data from " + n(countConcepts(FirstBytes), "files"); } }