Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5: change FS interface to have OpenFile() return an io.WriteCloser #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/codeclysm/extract/master/LICENSE)
[![Godoc Reference](https://img.shields.io/badge/Godoc-Reference-blue.svg)](https://godoc.org/github.com/codeclysm/extract)

import "github.com/codeclysm/extract/v4"
import "github.com/codeclysm/extract/v5"

Package extract allows to extract archives in zip, tar.gz or tar.bz2 formats
easily.
Expand Down
2 changes: 1 addition & 1 deletion extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (f fs) Symlink(oldname, newname string) error {
return os.Symlink(oldname, newname)
}

func (f fs) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) {
func (f fs) OpenFile(name string, flag int, perm os.FileMode) (io.WriteCloser, error) {
return os.OpenFile(name, flag, perm)
}

Expand Down
2 changes: 1 addition & 1 deletion extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"testing"

"github.com/arduino/go-paths-helper"
"github.com/codeclysm/extract/v4"
"github.com/codeclysm/extract/v5"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Extractor struct {
MkdirAll(path string, perm os.FileMode) error

// OpenFile opens the named file with specified flag (O_RDONLY etc.).
OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
OpenFile(name string, flag int, perm os.FileMode) (io.WriteCloser, error)

// Symlink creates newname as a symbolic link to oldname.
Symlink(oldname, newname string) error
Expand Down
5 changes: 3 additions & 2 deletions extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bytes"
"context"
"fmt"
"io"
"os"
"path/filepath"
"runtime"
Expand All @@ -14,7 +15,7 @@ import (
"testing"

"github.com/arduino/go-paths-helper"
"github.com/codeclysm/extract/v4"
"github.com/codeclysm/extract/v5"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -351,7 +352,7 @@ func (m MockDisk) Symlink(oldname, newname string) error {
return os.Symlink(oldname, newname)
}

func (m MockDisk) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) {
func (m MockDisk) OpenFile(name string, flag int, perm os.FileMode) (io.WriteCloser, error) {
name = filepath.Join(m.Base, name)
return os.OpenFile(name, flag, perm)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/codeclysm/extract/v4
module github.com/codeclysm/extract/v5

go 1.22

Expand Down
3 changes: 2 additions & 1 deletion loggingfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package extract_test

import (
"fmt"
"io"
"os"
)

Expand Down Expand Up @@ -88,7 +89,7 @@ func (m *LoggingFS) Symlink(oldname, newname string) error {
return err
}

func (m *LoggingFS) OpenFile(name string, flags int, perm os.FileMode) (*os.File, error) {
func (m *LoggingFS) OpenFile(name string, flags int, perm os.FileMode) (io.WriteCloser, error) {
f, err := os.OpenFile(name, flags, perm)
op := &LoggedOp{
Op: "open",
Expand Down