use of org.olat.core.util.vfs.LocalImpl in project OpenOLAT by OpenOLAT.
the class DataStepForm method isSame.
private boolean isSame(VFSItem currentTarget, File uploadedFile) {
if (currentTarget instanceof LocalImpl) {
LocalImpl local = (LocalImpl) currentTarget;
File currentFile = local.getBasefile();
if (currentFile.length() == uploadedFile.length()) {
try {
return org.apache.commons.io.FileUtils.contentEquals(currentFile, uploadedFile);
} catch (IOException e) {
logError("", e);
// do nothing -> return false at the end
}
}
}
return false;
}
use of org.olat.core.util.vfs.LocalImpl in project openolat by klemens.
the class WebDocumentRunController method getWebDocument.
private LocalFileImpl getWebDocument(RepositoryEntry entry) {
OLATResource resource = entry.getOlatResource();
VFSContainer fResourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
LocalFileImpl document = null;
for (VFSItem item : fResourceFileroot.getItems()) {
if (item instanceof VFSLeaf && item instanceof LocalImpl) {
LocalFileImpl localItem = (LocalFileImpl) item;
if (localItem != null && !localItem.getBasefile().isHidden()) {
document = (LocalFileImpl) item;
}
}
}
return document;
}
use of org.olat.core.util.vfs.LocalImpl in project openolat by klemens.
the class DataStepForm method isSame.
private boolean isSame(VFSItem currentTarget, File uploadedFile) {
if (currentTarget instanceof LocalImpl) {
LocalImpl local = (LocalImpl) currentTarget;
File currentFile = local.getBasefile();
if (currentFile.length() == uploadedFile.length()) {
try {
return org.apache.commons.io.FileUtils.contentEquals(currentFile, uploadedFile);
} catch (IOException e) {
logError("", e);
// do nothing -> return false at the end
}
}
}
return false;
}
use of org.olat.core.util.vfs.LocalImpl in project openolat by klemens.
the class WorkThreadInformations method setInfoFiles.
public static void setInfoFiles(String filePath, VFSLeaf leaf) {
try {
File file = new File(WebappHelper.getUserDataRoot(), "threadInfos");
if (!file.exists()) {
file.mkdirs();
}
if (leaf instanceof LocalImpl) {
filePath = ((LocalImpl) leaf).getBasefile().getAbsolutePath();
}
File infoFile = new File(file, Thread.currentThread().getName());
FileUtils.save(infoFile, filePath, "UTF-8");
} catch (Exception e) {
log.error("Cannot write info message about FolderIndexerWorker: " + filePath, e);
}
}
use of org.olat.core.util.vfs.LocalImpl in project openolat by klemens.
the class ZipUtil method addToZip.
public static boolean addToZip(VFSItem vfsItem, String currentPath, ZipOutputStream out) {
boolean success = true;
InputStream in = null;
byte[] buffer = new byte[FileUtils.BSIZE];
try {
// The separator / is the separator defined by the ZIP standard
String itemName = currentPath.length() == 0 ? vfsItem.getName() : currentPath + "/" + vfsItem.getName();
if (vfsItem instanceof VFSContainer) {
out.putNextEntry(new ZipEntry(itemName + "/"));
out.closeEntry();
List<VFSItem> items = ((VFSContainer) vfsItem).getItems();
for (Iterator<VFSItem> iter = items.iterator(); iter.hasNext(); ) {
if (!addToZip(iter.next(), itemName, out)) {
success = false;
break;
}
}
} else {
out.putNextEntry(new ZipEntry(itemName));
in = ((VFSLeaf) vfsItem).getInputStream();
int c;
while ((c = in.read(buffer, 0, buffer.length)) != -1) {
out.write(buffer, 0, c);
}
out.closeEntry();
}
} catch (IOException ioe) {
String name = vfsItem.getName();
if (vfsItem instanceof LocalImpl) {
name = ((LocalImpl) vfsItem).getBasefile().getAbsolutePath();
}
log.error("I/O error while adding " + name + " to zip:" + ioe);
return false;
} finally {
FileUtils.closeSafely(in);
}
return success;
}
Aggregations