/** * Adds a URL entry to the archive with the specified permissions. * * @param path the destination path for the installed file. * @param source the URL with the data to be added * @param permissions the permissions flags. * @param directive directive indicating special handling for this file. * @param uname user owner for the given file * @param gname group owner for the given file */ public synchronized void addURL( final String path, final URL source, final int permissions, final Directive directive, final String uname, final String gname, final int dirmode) throws FileNotFoundException { if (files.contains(path)) return; addParents(new File(path), dirmode, uname, gname); files.add(path); logger.log(FINE, "Adding file ''{0}''.", path); CpioHeader header = new CpioHeader(path, source); header.setType(FILE); header.setInode(inode++); if (uname != null) header.setUname(uname); if (gname != null) header.setGname(gname); if (permissions != -1) header.setPermissions(permissions); headers.add(header); sources.put(header, source); if (directive != null) header.setFlags(directive.flag()); }
/** * Adds a directory entry to the archive with the specified permissions. * * @param path the destination path for the installed file. * @param permissions the permissions flags. * @param directive directive indicating special handling for this directory. * @param uname user owner for the given file * @param gname group owner for the given file * @param addParents whether to add parent directories to the rpm */ public synchronized void addDirectory( final String path, final int permissions, final Directive directive, final String uname, final String gname, boolean addParents) { if (files.contains(path)) return; if (addParents) addParents(new File(path), permissions, uname, gname); files.add(path); logger.log(FINE, "Adding directory ''{0}''.", path); CpioHeader header = new CpioHeader(path); header.setType(DIR); header.setInode(inode++); if (uname != null) header.setUname(uname); if (gname != null) header.setGname(gname); header.setMtime(System.currentTimeMillis()); if (permissions != -1) header.setPermissions(permissions); else header.setPermissions(DEFAULT_DIRECTORY_PERMISSION); headers.add(header); sources.put(header, ""); if (directive != null) header.setFlags(directive.flag()); }