diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6d96c15
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,16 @@
+.classpath
+.project
+.settings/
+*.class
+*.zip
+*.jar
+*.tar.gz
+/target/
+/src/test/data/*~
+/src/test/data/*.log
+/src/test/data/cameradata/
+/src/test/data/output
+nbbuild.xml
+nbactions.xml
+Thumbs.db
+/nbproject/
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..c3b7eb6
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,162 @@
+
+ 4.0.0
+ haya4.tools
+ haya4-compress
+ 0.0.1-SNAPSHOT
+ compress
+ file commands use by 'org.apache.commons'.
+
+
+
+ MIT License
+ http://www.opensource.org/licenses/mit-license.php
+
+
+
+
+
+ Yuu Hayashi
+ hayashi.yuu@gmail.com
+ surveyor
+ http://surveyor.mydns.jp/
+
+
+
+
+ UTF-8
+ 1.8
+ ${java.version}
+ ${java.version}
+
+
+
+
+ org.apache.commons
+ commons-compress
+ 1.14
+ jar
+
+
+
+
+ org.hamcrest
+ hamcrest-core
+ 2.2
+ test
+ jar
+
+
+ junit
+ junit
+ 4.12
+ test
+ jar
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+
+ ${java.version}
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.1.0
+
+ UTF-8
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+ target/jacoco.exec
+
+
+ false
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.5
+
+
+
+ prepare-agent
+
+
+
+ default-report
+
+ report
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+ 3.7.1
+
+ ja
+ ${project.build.sourceEncoding}
+ ${site.encoding}
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-report-plugin
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+
+ protected
+ UTF-8
+ UTF-8
+ UTF-8
+
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.5
+
+
+
+ report
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/haya4/tools/files/compless/UnZip.java b/src/main/java/haya4/tools/files/compless/UnZip.java
new file mode 100644
index 0000000..95d45c8
--- /dev/null
+++ b/src/main/java/haya4/tools/files/compless/UnZip.java
@@ -0,0 +1,118 @@
+package haya4.tools.files.compless;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.FileTime;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
+
+public class UnZip {
+
+ /**
+ * *.tar.gz解凍
+ * ファイル更新日時をオリジナルと同じにします。
+ * @param tazFile 解凍する*.tar.gzファイル
+ * @param dest 解凍先フォルダ
+ * @throws IOException
+ */
+ public static void uncompress(Path tazFile, Path dest) throws IOException {
+ Files.createDirectories(dest);
+ try (TarArchiveInputStream tarIn = new TarArchiveInputStream(new GzipCompressorInputStream(new BufferedInputStream(Files.newInputStream(tazFile))))) {
+ TarArchiveEntry tarEntry = tarIn.getNextTarEntry();
+ while (tarEntry != null) {
+ Path destPath = Paths.get(dest.toString(), tarEntry.getName());
+ if (tarEntry.isDirectory()) {
+ Files.createDirectories(destPath);
+ }
+ else {
+ Path dir = destPath.getParent();
+ if (!Files.exists(dir)) {
+ Files.createDirectories(dir);
+ }
+ if (!Files.exists(destPath)) {
+ Files.createFile(destPath);
+ }
+ byte[] btoRead = new byte[1024];
+ try (BufferedOutputStream bout = new BufferedOutputStream(Files.newOutputStream(destPath))) {
+ int len;
+ while ((len = tarIn.read(btoRead)) != -1) {
+ bout.write(btoRead, 0, len);
+ }
+ }
+ Files.setLastModifiedTime(destPath, FileTime.fromMillis(tarEntry.getLastModifiedDate().getTime()));
+ }
+ tarEntry = tarIn.getNextTarEntry();
+ }
+ }
+ }
+
+ /**
+ * Zipファイルを展開します
+ * @param aZipFile zipファイル
+ * @param aOutDir 出力先ディレクトリ
+ * @throws java.io.IOException
+ */
+ public static void decode(Path aZipFile, String aOutDir) throws IOException {
+ Path outDir = Paths.get(aOutDir);
+ Files.createDirectories(outDir);
+
+ try (ZipInputStream zipIn = new ZipInputStream(Files.newInputStream(aZipFile))) {
+
+ ZipEntry entry = null;
+ while ((entry = zipIn.getNextEntry()) != null) {
+ if (entry.isDirectory()) {
+ String relativePath = entry.getName();
+ outDir = Paths.get(outDir.toString(), relativePath);
+ Files.createDirectories(outDir);
+ }
+ else {
+ String relativePath = entry.getName();
+ Path outFile = Paths.get(outDir.toString(), relativePath);
+
+ Path parentFile = outFile.getParent();
+ Files.createDirectories(parentFile);
+
+ try (OutputStream fileOut = Files.newOutputStream(outFile)) {
+ byte[] buf = new byte[ 256 ];
+ int size = 0;
+ while ((size = zipIn.read(buf)) > 0){
+ fileOut.write(buf, 0, size);
+ }
+ }
+ }
+ zipIn.closeEntry();
+ }
+ }
+ }
+
+
+ /**
+ * 空でないディレクトリを削除
+ * @param file
+ * @throws IOException
+ */
+ public static boolean delete(Path file) throws IOException {
+ if (Files.exists(file)) {
+ if (Files.isDirectory(file)) {
+ List files = Files.list(file).collect(Collectors.toList());
+ for (Path file1 : files) {
+ if (!delete(file1))
+ return false; // 再帰呼び出し
+ }
+ }
+ Files.delete(file);
+ }
+ return true;
+ }
+}
diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt
new file mode 100644
index 0000000..a37e276
--- /dev/null
+++ b/src/main/resources/LICENSE.txt
@@ -0,0 +1,43 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Yuu Hayashi
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+
+以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下「ソフトウェア」)の複製を取得するすべて
+の人に対し、ソフトウェアを無制限に扱うことを無償で許可します。これには、ソフトウェアの複製を使用、複写、変
+更、結合、掲載、頒布、サブライセンス、および/または販売する権利、およびソフトウェアを提供する相手に同じこ
+とを許可する権利も無制限に含まれます。
+
+上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。
+
+ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証もなく提供されます。ここでいう保証
+とは、商品性、特定の目的への適合性、および権利非侵害についての保証も含みますが、それに限定されるもので
+はありません。 作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、ソフトウェアに起因または
+関連し、あるいはソフトウェアの使用またはその他の扱いによって生じる一切の請求、損害、その他の義務について何
+らの責任も負わないものとします。
+
+----------------
+
+osm.jp.gpx.GeoDistance.java は'やまだらけ'様の著作物です。
+ Copyright (C) 2007-2012 やまだらけ
+ The MIT License (MIT)
+ 参照元: http://yamadarake.jp/trdi/report000001.html
+ 「Cords.java」を改変
diff --git a/src/main/resources/README.md b/src/main/resources/README.md
new file mode 100644
index 0000000..cab1d85
--- /dev/null
+++ b/src/main/resources/README.md
@@ -0,0 +1,13 @@
+# haya4-compress
+
+Example for use 'apache.compress'.
+
+## See
+
+* [haya4-compress wiki](http://surveyor.mydns.jp/gitbucket/yuu/haya4-compress/wiki)
+
+## License
+
+* [MIT License](LICENSE.txt)
+
+-------------------------------------------------------------------
diff --git a/src/test/java/haya4/tools/files/compless/UnZipTest.java b/src/test/java/haya4/tools/files/compless/UnZipTest.java
new file mode 100644
index 0000000..6076c7c
--- /dev/null
+++ b/src/test/java/haya4/tools/files/compless/UnZipTest.java
@@ -0,0 +1,49 @@
+package haya4.tools.files.compless;
+
+import static org.junit.Assert.*;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.junit.Test;
+
+public class UnZipTest {
+
+ @Test
+ public void uncompressTest() {
+ Path testFile = Paths.get("target/test-classes/images.tar.gz");
+ Path outDir = Paths.get("target/test-classes/");
+ Path destDir = Paths.get("target/test-classes/images");
+ try {
+ UnZip.uncompress(testFile, outDir);
+ assertTrue(Files.exists(destDir));
+ assertTrue(Files.isDirectory(destDir));
+
+ boolean ret = UnZip.delete(destDir);
+ assertTrue(ret);
+ assertFalse(Files.exists(destDir));
+ }
+ catch(Exception e) {
+ fail(e.toString());
+ }
+ }
+
+ @Test
+ public void decodeTest() {
+ Path testFile = Paths.get("target/test-classes/images.zip");
+ Path destDir = Paths.get("target/test-classes/images");
+ try {
+ UnZip.decode(testFile, "target/test-classes");
+ assertTrue(Files.exists(destDir));
+ assertTrue(Files.isDirectory(destDir));
+
+ boolean ret = UnZip.delete(destDir);
+ assertTrue(ret);
+ assertFalse(Files.exists(destDir));
+ }
+ catch(Exception e) {
+ fail(e.toString());
+ }
+ }
+}