/** * Creates a new zip entry taking some information from the given * file and using the provided name. * * <p />The name will be adjusted to end with a forward slash "/" if * the file is a directory. If the file is not a directory a * potential trailing forward slash will be stripped from the * entry name. */ public ZipArchiveEntry(java.io.File inputFile, String entryName) : base(inputFile.isDirectory() && !entryName.EndsWith("/") ? entryName + "/" : entryName) { setName(inputFile.isDirectory() && !entryName.EndsWith("/") ? entryName + "/" : entryName); if (inputFile.isFile()) { setSize(inputFile.length()); } setTime(inputFile.lastModified()); // TODO are there any other fields we can set here? }
/* * 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); }
protected void initOverFile(java.io.File file, String fileName) { this.file = file; this.linkName = ""; if (file.isDirectory()) { this.mode = DEFAULT_DIR_MODE; this.linkFlag = TarConstants.LF_DIR; int nameLength = fileName.length(); if (nameLength == 0 || fileName.charAt(nameLength - 1) != '/') { this.name = fileName + "/"; } else { this.name = fileName; } this.size = 0; } else { this.mode = DEFAULT_FILE_MODE; this.linkFlag = TarConstants.LF_NORMAL; this.size = file.length(); this.name = fileName; } this.modTime = file.lastModified() / MILLIS_PER_SECOND; this.devMajor = 0; this.devMinor = 0; }
/** * Return whether or not this entry represents a directory. * * @return True if this entry is a directory. */ public bool isDirectory() { if (file != null) { return(file.isDirectory()); } if (linkFlag == TarConstants.LF_DIR) { return(true); } if (getName().EndsWith("/")) { return(true); } return(false); }
/** * Creates a CPIOArchiveEntry with a specified name for a * specified file. * * @param format * The cpio format for this entry. * @param inputFile * The file to gather information from. * @param entryName * The name of this entry. * <br/> * Possible format values are: * <p> * CpioConstants.FORMAT_NEW<br/> * CpioConstants.FORMAT_NEW_CRC<br/> * CpioConstants.FORMAT_OLD_BINARY<br/> * CpioConstants.FORMAT_OLD_ASCII<br/> * * @since Apache Commons Compress 1.1 */ public CpioArchiveEntry(short format, java.io.File inputFile, String entryName) { this.setFileFormat(format); this.name = entryName; this.setSize(inputFile.isFile() ? inputFile.length() : 0); long mode = 0; if (inputFile.isDirectory()) { mode |= CpioConstants.C_ISDIR; } else if (inputFile.isFile()) { mode |= CpioConstants.C_ISREG; } else { throw new java.lang.IllegalArgumentException("Cannot determine type of file " + inputFile.getName()); } // TODO set other fields as needed setMode(mode); setTime(inputFile.lastModified() / 1000); }