unzipFile
tip
方法文档 Files.unzipFile()
kotlin
groovy
javascript
lua
php
python
ruby
val filesDir = _files.getFilesDir()
val src = _files.buildFile {
setPath(filesDir, "tmp/abc.txt")
}
src.writeText("hello world", "UTF-8")
val dest = _files.buildFile {
setPath(filesDir, "tmp/abc.zip")
}
_console.log(_files.zipFile(src, dest, null))
_console.log(dest.exists() && dest.isFile())
val unzipDir = _files.buildFile {
setPath(filesDir, "tmp/abc")
}
_console.log(_files.unzipFile(dest, unzipDir, null))
_console.log(unzipDir.exists() && unzipDir.isDirectory())
src.delete()
dest.delete()
unzipDir.deleteRecursively()
tip
def filesDir = $files.getFilesDir()
def src = $files.buildFile {
setPath(filesDir, "tmp/abc.txt")
}
src.writeText("hello world", "UTF-8")
def dest = $files.buildFile {
setPath(filesDir, "tmp/abc.zip")
}
$console.log($files.zipFile(src, dest, null))
$console.log(dest.exists() && dest.isFile())
def unzipDir = $files.buildFile {
setPath(filesDir, "tmp/abc")
}
$console.log($files.unzipFile(dest, unzipDir, null))
$console.log(unzipDir.exists() && unzipDir.isDirectory())
src.delete()
dest.delete()
unzipDir.deleteRecursively()
tip
let filesDir = $files.getFilesDir()
let src = $files.buildFile((fileBuilder) => {
fileBuilder.setPath(filesDir, "tmp/abc.txt")
})
src.writeText("hello world", "UTF-8")
let dest = $files.buildFile((fileBuilder) => {
fileBuilder.setPath(filesDir, "tmp/abc.zip")
})
$console.log($files.zipFile(src, dest, null))
$console.log(dest.exists() && dest.isFile())
let unzipDir = $files.buildFile((fileBuilder) => {
fileBuilder.setPath(filesDir, "tmp/abc")
})
$console.log($files.unzipFile(dest, unzipDir, null))
$console.log(unzipDir.exists() && unzipDir.isDirectory())
src.delete()
dest.delete()
unzipDir.deleteRecursively()
tip
local filesDir = _files:getFilesDir()
local src = _files:buildFile(function(fileBuilder)
fileBuilder:setPath(filesDir, "tmp/abc.txt")
end)
src:writeText("hello world", "UTF-8")
local dest = _files:buildFile(function(fileBuilder)
fileBuilder:setPath(filesDir, "tmp/abc.zip")
end)
_console:log(_files:zipFile(src, dest, nil))
_console:log(dest:exists() and dest:isFile())
local unzipDir = _files:buildFile(function(fileBuilder)
fileBuilder:setPath(filesDir, "tmp/abc")
end)
_console:log(_files:unzipFile(dest, unzipDir, nil))
_console:log(unzipDir:exists() and unzipDir:isDirectory())
src:delete()
dest:delete()
unzipDir:deleteRecursively()
tip
<?php
$filesDir = $files->getFilesDir();
$src = $files->buildFile(function ($fileBuilder) use ($filesDir) {
$fileBuilder->setPath($filesDir, "tmp/abc.txt");
});
$src->writeText("hello world", "UTF-8");
$dest = $files->buildFile(function ($fileBuilder) use ($filesDir) {
$fileBuilder->setPath($filesDir, "tmp/abc.zip");
});
$console->log($files->zipFile($src, $dest, null));
$console->log($dest->exists() and $dest->isFile());
$unzipDir = $files->buildFile(function ($fileBuilder) use ($filesDir) {
$fileBuilder->setPath($filesDir, "tmp/abc");
});
$console->log($files->unzipFile($dest, $unzipDir, null));
$console->log($unzipDir->exists() and $unzipDir->isDirectory());
$src->delete();
$dest->delete();
$unzipDir->deleteRecursively();
tip
filesDir = _files.getFilesDir()
def fn1(fileBuilder):
fileBuilder.setPath(filesDir, "tmp/abc.txt")
src = _files.buildFile(fn1)
src.writeText("hello world", "UTF-8")
def fn2(fileBuilder):
fileBuilder.setPath(filesDir, "tmp/abc.zip")
dest = _files.buildFile(fn2)
_console.log(_files.zipFile(src, dest, None))
_console.log(dest.exists() and dest.isFile())
def fn3(fileBuilder):
fileBuilder.setPath(filesDir, "tmp/abc")
unzipDir = _files.buildFile(fn3)
_console.log(_files.unzipFile(dest, unzipDir, None))
_console.log(unzipDir.exists() and unzipDir.isDirectory())
src.delete()
dest.delete()
unzipDir.deleteRecursively()
tip
filesDir = $files.getFilesDir()
src = $files.buildFile { |fileBuilder|
fileBuilder.setPath(filesDir, "tmp/abc.txt")
}
src.writeText("hello world", "UTF-8")
dest = $files.buildFile { |fileBuilder|
fileBuilder.setPath(filesDir, "tmp/abc.zip")
}
$console.log($files.zipFile(src, dest, nil))
$console.log(dest.exists() && dest.isFile())
unzipDir = $files.buildFile { |fileBuilder|
fileBuilder.setPath(filesDir, "tmp/abc")
}
$console.log($files.unzipFile(dest, unzipDir, nil))
$console.log(unzipDir.exists() && unzipDir.isDirectory())
src.delete()
dest.delete()
unzipDir.deleteRecursively()
tip