Package land.oras.utils
Class ArchiveUtils
java.lang.Object
land.oras.utils.ArchiveUtils
Archive utilities
-
Method Summary
Modifier and TypeMethodDescriptionstatic LocalPathCompress a tar file to a tar.gz or tar.zstd file depending on the requested media typestatic PathCreate a temporary directorystatic PathCreate a temporary archive when uploading directory layersstatic PathCreate a temporary zip file when uploading directory layers with zip media typestatic LocalPathCreate a tar file from a directory, prefixing every entry with the source directory's own name.static LocalPathCreate a tar file from a directory.static LocalPathtarcompress(LocalPath sourceDir, String mediaType) Create a tar compressed file from a directorystatic LocalPathuncompress(InputStream is, String mediaType) Extract a compressed file from a tar.gz or tar.zstd file depending on the requested media typestatic Pathuncompressuntar(Path path, String mediaType) Uncompress a compressed file and untar to a temporary directorystatic voiduncompressuntar(Path path, Path target, String mediaType) Uncompress a compressed file and untar it to the target directorystatic voiduntar(InputStream fis, Path target) Extract a tar file to a target directorystatic PathConvienience method to extract a tar file to a temporary directorystatic voidExtract a tar file to a target directorystatic voidExtract a zip file to a target directorystatic LocalPathZip a local source dire and return a temporary zip file as a local path
-
Method Details
-
createTempTar
Create a temporary archive when uploading directory layers- Returns:
- The path to the archive
-
createTempZip
Create a temporary zip file when uploading directory layers with zip media type- Returns:
- The path to the zip file
-
createTempDir
Create a temporary directory- Returns:
- The path to the temporary directory
-
zip
Zip a local source dire and return a temporary zip file as a local path- Parameters:
sourceDir- The source directory- Returns:
- The local path to the zip file
-
tar
Create a tar file from a directory, prefixing every entry with the source directory's own name.Equivalent to calling
tar(sourceDir, true).- Parameters:
sourceDir- The source directory- Returns:
- The local path to the temporary tar file
-
tar
Create a tar file from a directory.When
includeDirectoryNameistrue(the default behaviour) every entry is prefixed with the source directory's own name, e.g.mydir/blobs/sha256/.... Whenfalse, entries are stored relative to the source directory itself, e.g.blobs/sha256/...— which is the format required by the OCI Image Layout specification when packaging a layout as a plain tar archive.- Parameters:
sourceDir- The source directoryincludeDirectoryName-trueto prefix entries with the directory name,falsefor root-relative entry names- Returns:
- The local path to the temporary tar file
-
tarcompress
Create a tar compressed file from a directory- Parameters:
sourceDir- The source directorymediaType- The media type- Returns:
- The path to the tar compressed file
-
untar
Extract a tar file to a target directory- Parameters:
path- The tar filetarget- The target directory
-
uncompressuntar
Uncompress a compressed file and untar it to the target directory- Parameters:
path- The compressed filetarget- The target directorymediaType- The media type of the compressed file
-
uncompressuntar
Uncompress a compressed file and untar to a temporary directory- Parameters:
path- The compressed filemediaType- The media type of the compressed file- Returns:
- The path to the temporary directory
-
untar
Convienience method to extract a tar file to a temporary directory- Parameters:
path- The tar file- Returns:
- The path to the temporary directory
-
unzip
Extract a zip file to a target directory- Parameters:
path- The zip filetarget- The target directory
-
untar
Extract a tar file to a target directory- Parameters:
fis- The archive streamtarget- The target directory
-
compress
Compress a tar file to a tar.gz or tar.zstd file depending on the requested media type- Parameters:
path- The tar filemediaType- The target media type- Returns:
- The path to the tar.gz file or the tar.zstd file
-
uncompress
Extract a compressed file from a tar.gz or tar.zstd file depending on the requested media type- Parameters:
is- The compressed input streammediaType- The media type of the stream to select the uncompression method- Returns:
- The path to the tar.gz file or the tar.zstd file
-