Helper method for {@link #tar(FileSystem, FileSystem, Path, Path)} that adds a directory entry to a given
{@link TarArchiveOutputStream}.
162962
private static void dirToTarArchiveOutputStream(Path destDir, TarArchiveOutputStream tarArchiveOutputStream)
      throws IOException {
    TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(formatPathToDir(destDir));
    tarArchiveEntry.setModTime(System.currentTimeMillis());
    tarArchiveOutputStream.putArchiveEntry(tarArchiveEntry);
    tarArchiveOutputStream.closeArchiveEntry();
  }
1230897
private void addEntry(final Path pathToFile, final URL resource) throws IOException {

        final Path parent = pathToFile.getParent();
        if (parent != null) {
            addFolder(parent);
        }
        try (InputStream inputStream = resource.openStream()) {
            Files.copy(inputStream, pathToFile);
        }
    }
161665
public void addDir(String dirName) {
        Path dir = Paths.get(dirName);

        if (Files.isDirectory(dir)) {
            list.add(new DirPathEntry(dir));
        }
    }
1098745
public Jar addEntry(String path, byte[] content) throws IOException {
        beginWriting();
        addEntry(jos, path, content);
        return this;
    }
1015326
def packtar(tarfile, files, srcdir):
    
    nullfd = open(os.devnull, "w")
    tarfile = cygpath(os.path.abspath(tarfile))
    log.debug("pack tar %s from folder  %s with files ", tarfile, srcdir)
    log.debug(files)
    try:
        check_call([TAR, '-czf', tarfile] + files, cwd=srcdir,
                   stdout=nullfd, preexec_fn=_noumask)
    except Exception:
        log.exception("Error packing tar file %s to %s", tarfile, srcdir)
        raise
    nullfd.close()
936381
private void upload(String fileOrDir, String uploadRootDir) throws Exception {
        if (uploadRootDir.isEmpty())
            uploadRootDir = ".";
        File origin = new File(fileOrDir);

        if (fileOrDir.endsWith(".tar") || fileOrDir.endsWith(".tar.gz")) {
            upload(new File(fileOrDir), uploadRootDir);
            untar(uploadRootDir);
        } else if (origin.isFile()) {
            upload(new File(fileOrDir), uploadRootDir);
        } else {
            File[] childFiles = origin.listFiles();
            if (childFiles != null)
                upload(Arrays.asList(childFiles), uploadRootDir);

        }
    }
200168
public void queueEntry(String entryPath, InputStream inStream,
                           int maxBytes)
                           throws IOException, TarMalformatException {
        entryQueue.add(new TarEntrySupplicant(entryPath, inStream, maxBytes,
                                              '0', archive));
    }
227285
private static void addEntry(ZipEntrySource entry, ZipOutputStream out) throws IOException {
    out.putNextEntry(entry.getEntry());
    InputStream in = entry.getInputStream();
    if (in != null) {
      try {
        IOUtils.copy(in, out);
      }
      finally {
        IOUtils.closeQuietly(in);
      }
    }
    out.closeEntry();
  }
716714
public static void addInputPath(Job job, 
                                  Path path) throws IOException {
    Configuration conf = job.getConfiguration();
    FileSystem fs = FileSystem.get(conf);
    path = path.makeQualified(fs);
    String dirStr = StringUtils.escapeString(path.toString());
    String dirs = conf.get("mapred.input.dir");
    conf.set("mapred.input.dir", dirs == null ? dirStr : dirs + "," + dirStr);
  }
1101261
@Override
    public T add(final Archive<?> archive, final ArchivePath path, final Class<? extends StreamExporter> exporter) {
        // Add archive asset
        super.add(archive, path, exporter);

        // Expected Archive Path
        final ArchivePath archivePath = new BasicPath(path, archive.getName());

        // Get the Asset that was just added
        final Node node = get(archivePath);

        // Make sure it is an ArchiveAsset
        if (node.getAsset() != null && node.getAsset() instanceof ArchiveAsset) {
            final ArchiveAsset archiveAsset = ArchiveAsset.class.cast(node.getAsset());
            // Add asset to ArchiveAsset Map
            nestedArchives.put(archivePath, archiveAsset);
        }

        return covariantReturn();
    }
965567
private static void addFile(InputStream in, String path, ZipOutputStream out) throws UtilException {
		if (null == in) {
			return;
		}
		try {
			out.putNextEntry(new ZipEntry(path));
			IoUtil.copy(in, out);
		} catch (IOException e) {
			throw new UtilException(e);
		} finally {
			closeEntry(out);
		}
	}
775302
function addToPath(directory) {
  var srcs = process.env.PATH.split(delimiter);
  if (srcs.indexOf(directory) === -1) {
    srcs.unshift(directory);
    process.env.PATH = srcs.join(delimiter);
    debug('added `%s` to $PATH and its now `%s`',
      directory, process.env.PATH);
  }
}
1140696
public Jar addEntry(Path path, Path file) throws IOException {
        return addEntry(path, Files.newInputStream(file));
    }
643767
private static void addFolderToZip(String path, File folder, ZipOutputStream zos) throws IOException {
        String currentPath = StringUtils.isNotEmpty(path)? path + "/" + folder.getName(): folder.getName();

        for (File file : folder.listFiles()) {
            if (file.isDirectory()) {
                addFolderToZip(currentPath, file, zos);
            } else {
                addFileToZip(currentPath, file, zos);
            }
        }
    }
883524
def add_docker_file_to_tarfile(self, docker_file, tar):
        """"""
        with hp.a_temp_file() as dockerfile:
            log.debug("Context: ./Dockerfile")
            dockerfile.write("\n".join(docker_file.docker_lines).encode('utf-8'))
            dockerfile.seek(0)
            tar.add(dockerfile.name, arcname="./Dockerfile")
376164
public static OutputStream asOututStream(Path path) throws IOException {
		Validate.notNull(path, "path is null");
		return Files.newOutputStream(path);
	}
293710
private void addEntries(final FileSystem zipFs) throws IOException {

        for (Map.Entry<String, URL> entry : contentMap.entrySet()) {
            final Path pathToFile = zipFs.getPath(entry.getKey());
            final URL resource = entry.getValue();
            addResource(pathToFile, resource);
        }
    }