Пример #1
0
 /**
  * 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.
  */
 public synchronized void addLink(String path, final String target, int permissions) {
   if (files.contains(path)) return;
   files.add(path);
   logger.log(FINE, "Adding link ''{0}''.", path);
   CpioHeader header = new CpioHeader(path);
   header.setType(SYMLINK);
   header.setFileSize(target.length());
   header.setMtime(System.currentTimeMillis());
   if (permissions != -1) header.setPermissions(permissions);
   headers.add(header);
   sources.put(header, target);
 }
Пример #2
0
  /**
   * 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());
  }