Compare commits
6 Commits
9b42459dc3
...
master
Author | SHA1 | Date | |
---|---|---|---|
b59f329199 | |||
0498b70454 | |||
e7452feddf | |||
643df15eb8 | |||
fb28920794 | |||
11c5657f4f |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,5 @@
|
|||||||
# Mac
|
# Mac
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# Test out
|
||||||
|
/test/out
|
||||||
|
@ -19,8 +19,5 @@ cache:
|
|||||||
before_install:
|
before_install:
|
||||||
- echo "TRAVIS_GO_VERSION=${TRAVIS_GO_VERSION}"
|
- echo "TRAVIS_GO_VERSION=${TRAVIS_GO_VERSION}"
|
||||||
|
|
||||||
install:
|
|
||||||
- go mod install
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- go test -v
|
- go test -v
|
||||||
|
11
README.md
11
README.md
@ -4,3 +4,14 @@
|
|||||||
[](https://godoc.org/github.com/yi-ge/unxz)
|
[](https://godoc.org/github.com/yi-ge/unxz)
|
||||||
[](https://codebeat.co/projects/github-com-yi-ge-unxz-master)
|
[](https://codebeat.co/projects/github-com-yi-ge-unxz-master)
|
||||||
[](https://goreportcard.com/report/github.com/yi-ge/unxz)
|
[](https://goreportcard.com/report/github.com/yi-ge/unxz)
|
||||||
|
|
||||||
|
Golang \*.tar.xz decompress.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```golang
|
||||||
|
import "github.com/yi-ge/unxz"
|
||||||
|
|
||||||
|
u := unxz.New(filePath, outDir)
|
||||||
|
err := u.Extract()
|
||||||
|
```
|
||||||
|
@ -1 +0,0 @@
|
|||||||
1
|
|
@ -1,2 +0,0 @@
|
|||||||
2
|
|
||||||
123
|
|
@ -1 +0,0 @@
|
|||||||
dir/d.txt
|
|
@ -1,2 +0,0 @@
|
|||||||
2
|
|
||||||
123
|
|
@ -1 +0,0 @@
|
|||||||
3
|
|
@ -1 +0,0 @@
|
|||||||
4abcde
|
|
@ -1 +0,0 @@
|
|||||||
../f.txt
|
|
@ -1 +0,0 @@
|
|||||||
4abcde
|
|
@ -1 +0,0 @@
|
|||||||
5
|
|
40
unxz_test.go
40
unxz_test.go
@ -17,7 +17,7 @@ func currentDir() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testNullContent(t *testing.T) {
|
func testNullContent(t *testing.T) {
|
||||||
aFile, err := os.Open(path.Join(currentDir(), "./test/a.txt"))
|
aFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/a.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ func testNullContent(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
aOutFile, err := os.Open(path.Join(currentDir(), "./test/out/a.txt"))
|
aOutFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/a.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ func testNullContent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testContentEqual(t *testing.T) {
|
func testContentEqual(t *testing.T) {
|
||||||
bFile, err := os.Open(path.Join(currentDir(), "./test/b.txt"))
|
bFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/b.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ func testContentEqual(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
bOutFile, err := os.Open(path.Join(currentDir(), "./test/out/b.txt"))
|
bOutFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/b.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ func testContentEqual(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testLink(t *testing.T) {
|
func testLink(t *testing.T) {
|
||||||
cOutFile, err := os.OpenFile(path.Join(currentDir(), "./test/out/c.txt"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
|
cOutFile, err := os.OpenFile(filepath.FromSlash(path.Join(currentDir(), "./test/out/c.txt")), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ func testLink(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cOutLinkFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/c.txt"))
|
cOutLinkFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/c.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ func testLink(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cOutFileNew, err := os.Open(path.Join(currentDir(), "./test/out/c.txt"))
|
cOutFileNew, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/c.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ func testLink(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log("New c.txt content:", string(cOutFileContentNew))
|
t.Log("New c.txt content:", string(cOutFileContentNew))
|
||||||
|
|
||||||
cOutLinkFileNew, err := os.Open(path.Join(currentDir(), "./test/out/dir/c.txt"))
|
cOutLinkFileNew, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/c.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -141,16 +141,16 @@ func testLink(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testSymlink(t *testing.T) {
|
func testSymlink(t *testing.T) {
|
||||||
targetURL, err := filepath.EvalSymlinks(path.Join(currentDir(), "./test/out/d.txt"))
|
targetURL, err := filepath.EvalSymlinks(filepath.FromSlash(path.Join(currentDir(), "./test/out/d.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if targetURL != path.Join(currentDir(), "./test/out/dir/d.txt") {
|
if targetURL != filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/d.txt")) {
|
||||||
t.Fatal("Unxz file Symlink error.")
|
t.Fatal("Unxz file Symlink error.")
|
||||||
}
|
}
|
||||||
|
|
||||||
dOutSymlinkFile, err := os.Open(path.Join(currentDir(), "./test/out/d.txt"))
|
dOutSymlinkFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/d.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ func testSymlink(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dOutFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/d.txt"))
|
dOutFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/d.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ func testSymlink(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testLintInDir(t *testing.T) {
|
func testLintInDir(t *testing.T) {
|
||||||
eOutFile, err := os.OpenFile(path.Join(currentDir(), "./test/out/dir/dir/e.txt"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
|
eOutFile, err := os.OpenFile(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/dir/e.txt")), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ func testLintInDir(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
eOutLinkFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/e.txt"))
|
eOutLinkFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/e.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ func testLintInDir(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
eOutFileNew, err := os.Open(path.Join(currentDir(), "./test/out/dir/dir/e.txt"))
|
eOutFileNew, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/dir/e.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ func testLintInDir(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log("New dir/dir/e.txt content:", string(eOutFileContentNew))
|
t.Log("New dir/dir/e.txt content:", string(eOutFileContentNew))
|
||||||
|
|
||||||
eOutLinkFileNew, err := os.Open(path.Join(currentDir(), "./test/out/dir/e.txt"))
|
eOutLinkFileNew, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/e.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -240,17 +240,17 @@ func testLintInDir(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testSymlinkInDir(t *testing.T) {
|
func testSymlinkInDir(t *testing.T) {
|
||||||
inDirTargetURL, err := filepath.EvalSymlinks(path.Join(currentDir(), "./test/out/dir/dir/f.txt"))
|
inDirTargetURL, err := filepath.EvalSymlinks(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/dir/f.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Log("F outSymlinkFile link:", inDirTargetURL)
|
t.Log("F outSymlinkFile link:", inDirTargetURL)
|
||||||
|
|
||||||
if inDirTargetURL != path.Join(currentDir(), "./test/out/dir/f.txt") {
|
if inDirTargetURL != filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/f.txt")) {
|
||||||
t.Fatal("Unxz file Symlink error.")
|
t.Fatal("Unxz file Symlink error.")
|
||||||
}
|
}
|
||||||
|
|
||||||
fOutSymlinkFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/dir/f.txt"))
|
fOutSymlinkFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/dir/f.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -261,7 +261,7 @@ func testSymlinkInDir(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fOutFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/f.txt"))
|
fOutFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/f.txt")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user