Update of /cvsroot/openantivirus/java/src/org/openantivirus/engine/vfs
In directory sc8-pr-cvs1:/tmp/cvs-serv4777/java/src/org/openantivirus/engine/vfs
Added Files:
TemporaryFile.java VfsContainer.java TemporaryDirectory.java
VfsEntry.java VfsContainerFactory.java
Log Message:
Rewrite of the engine to use a virtual file system
Move to 'engine' subdirectory
Added bzip2 and tar decompressors
Switch from GPL to MPL
--- NEW FILE: TemporaryFile.java ---
/*
* $Id: TemporaryFile.java,v 1.1 2003/12/14 11:08:26 kurti Exp $
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OAV.
*
* The Initial Developer of the Original Code is Kurt Huwig <[email protected]>.
* Portions created by the Initial Developer are Copyright (C) 2001-2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
package org.openantivirus.engine.vfs;
import java.io.*;
import org.openantivirus.engine.*;
/**
* Creates a temporary file that is deleted upon 'dispose'
*
* Pattern-Roles:
* @author Kurt Huwig <[email protected]>
* @version $Revision: 1.1 $
*/
public class TemporaryFile {
private static final String TEMP_PREFIX = "file",
TEMP_SUFFIX = ".oav";
private final File tempFile;
public TemporaryFile(ScanConfiguration scanConfiguration)
throws IOException {
tempFile = File.createTempFile(
TEMP_PREFIX,
TEMP_SUFFIX,
new File(scanConfiguration.getString("tempdirectory")));
}
public File getFile() {
return tempFile;
}
/** called if the VfsEntry is not needed any more */
public void delete() throws IOException {
tempFile.delete();
}
}
--- NEW FILE: VfsContainer.java ---
/*
* $Id: VfsContainer.java,v 1.1 2003/12/14 11:08:26 kurti Exp $
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OAV.
*
* The Initial Developer of the Original Code is Kurt Huwig <[email protected]>.
* Portions created by the Initial Developer are Copyright (C) 2001-2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
package org.openantivirus.engine.vfs;
import java.io.*;
/**
* A vfs entry that contains other entries
*
* Pattern-Roles:
* @author Kurt Huwig <[email protected]>
* @version $Revision: 1.1 $
*/
public interface VfsContainer {
/** @return if there are more VfsEntrys in this container */
boolean hasNext();
/** @return next VfsEntry within this container */
VfsEntry next() throws IOException;
/**
* called if the VfsContainer is not needed any more; no method may be
* called afterwards.
*/
void dispose() throws IOException;
}
--- NEW FILE: TemporaryDirectory.java ---
/*
* $Id: TemporaryDirectory.java,v 1.1 2003/12/14 11:08:26 kurti Exp $
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OAV.
*
* The Initial Developer of the Original Code is Kurt Huwig <[email protected]>.
* Portions created by the Initial Developer are Copyright (C) 2001-2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
package org.openantivirus.engine.vfs;
import java.io.*;
import org.openantivirus.engine.*;
/**
* Creates a temporary directory that is deleted upon 'dispose'
*
* Pattern-Roles:
* @author Kurt Huwig <[email protected]>
* @version $Revision: 1.1 $
*/
public class TemporaryDirectory {
private final File tempDir;
public TemporaryDirectory(ScanConfiguration scanConfiguration) {
final File baseDir = new File(
scanConfiguration.getString("tempdirectory"));
long id = System.currentTimeMillis();
File dir;
do {
dir = new File(baseDir, Long.toString(id++));
}
while (!dir.mkdir());
tempDir = dir;
}
public File getDirectory() {
return tempDir;
}
/** called if the VfsEntry is not needed any more */
public void delete() throws IOException {
delete(tempDir);
}
protected void delete(File directory) throws IOException {
final File[] files = directory.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
final File file = files[i];
if (file.isDirectory()) {
delete(file);
}
file.delete();
}
}
directory.delete();
}
}
--- NEW FILE: VfsEntry.java ---
/*
* $Id: VfsEntry.java,v 1.1 2003/12/14 11:08:26 kurti Exp $
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OAV.
*
* The Initial Developer of the Original Code is Kurt Huwig <[email protected]>.
* Portions created by the Initial Developer are Copyright (C) 2001-2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
package org.openantivirus.engine.vfs;
import java.io.*;
/**
* An entry in the vfs
*
* Pattern-Roles:
* @author Kurt Huwig <[email protected]>
* @version $Revision: 1.1 $
*/
public interface VfsEntry {
int MAX_START_SIZE = 4096;
/** @return File this entry represents */
File getFile() throws IOException;
/**
* @return the first block of bytes from the object; should be at least 4kB
*/
byte[] getStart() throws IOException;
/**
* called if the VfsEntry is not needed any more; no method may be called
* afterwards.
*/
void dispose() throws IOException;
/** @return (file-)name of the entry */
String getName();
}
--- NEW FILE: VfsContainerFactory.java ---
/*
* $Id: VfsContainerFactory.java,v 1.1 2003/12/14 11:08:26 kurti Exp $
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OAV.
*
* The Initial Developer of the Original Code is Kurt Huwig <[email protected]>.
* Portions created by the Initial Developer are Copyright (C) 2001-2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
package org.openantivirus.engine.vfs;
import java.io.*;
import org.openantivirus.engine.*;
/**
* Creates VfsContainers
*
* Pattern-Roles: Factory
* @author Kurt Huwig <[email protected]>
* @version $Revision: 1.1 $
*/
public interface VfsContainerFactory {
/**
* @return VfsContainer that handles this entry or null if this factory
* cannot handle this container
*/
VfsContainer getContainer(VfsEntry entry, ScanConfiguration configuration)
throws IOException;
}
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.