/* * Opens a file as <i>ZIP-archive</i>. "mode" must be {@code OPEN_READ} or * {@code OPEN_DELETE} . The latter sets the "delete on exit" flag through a * file. * * @param file * the ZIP file to read. * @param mode * the mode of the file open operation. * @throws IOException * if an {@code IOException} occurs. */ public ZipFile(java.io.File file, int mode) //throws IOException { { fileName = file.getPath(); if (mode != OPEN_READ && mode != (OPEN_READ | OPEN_DELETE)) { throw new java.lang.IllegalArgumentException(); } /* java.lang.SecurityManager security = java.lang.SystemJ.getSecurityManager(); * if (security != null) { * security.checkRead(fileName); * }*/ if ((mode & OPEN_DELETE) != 0) { /* if (security != null) { * security.checkDelete(fileName); * }*/ fileToDeleteOnClose = file; // file.deleteOnExit(); } else { fileToDeleteOnClose = null; } mRaf = new java.io.RandomAccessFile(fileName, "r"); readCentralDir(); }
/* * Scan the given directory for files containing the substrMatch<br> * Small case extensions '.dbf' are recognized and returned as '.DBF' */ public static java.util.Vector <Object> getAllFiles(String path, String suffix) { java.util.Vector <Object> vec = null; String[] fileNameList; java.io.File currentDir, f; String fileName, upperSuffix; int i; upperSuffix = suffix.toUpperCase(); currentDir = new java.io.File(path); fileNameList = currentDir.list(); if (fileNameList == null) { java.lang.SystemJ.outJ.println("*** null for " + path); } else { vec = new java.util.Vector <Object>(fileNameList.Length); for (i = 0; i < fileNameList.Length; i++) { f = new java.io.File(fileNameList[i]); if (!f.isDirectory()) { fileName = f.getPath().toString().toUpperCase(); // lastModified = new java.util.Date(f.lastModified()); if (upperSuffix == null | fileName.endsWith(upperSuffix)) { vec.addElement(f); } } } } return(vec); }
/** * Create a new {@code JarFile} using the contents of file. * * @param file * the JAR file as {@link File}. * @param verify * if this JAR filed is signed whether it must be verified. * @param mode * the mode to use, either {@link ZipFile#OPEN_READ OPEN_READ} or * {@link ZipFile#OPEN_DELETE OPEN_DELETE}. * @throws IOException * If the file cannot be read. */ public JarFile(java.io.File file, bool verify, int mode) ://throws IOException { base(file, mode) { if (verify) { verifier = new JarVerifier(file.getPath()); } readMetaEntries(); }
/** * Construct an entry for a file. File is set to file, and the * header is constructed from information from the file. * The name is set from the normalized file path. * * @param file The file that the entry represents. */ public TarArchiveEntry(java.io.File file) { initOverFile(file, normalizeFileName(file.getPath(), false)); }