Skip to content

Commit e84df8f

Browse files
dmcgowanclaude
andcommitted
Rename EroFS to Open and Opt to OpenOpt
Rename the primary API entry point from EroFS() to Open() for a cleaner, more idiomatic Go API. Rename Opt to OpenOpt to distinguish reader options from the upcoming Create() writer options. The old names are preserved as deprecated type aliases and wrapper functions for backwards compatibility, to be removed in 0.3. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Derek McGowan <derek@mcg.dev>
1 parent 62af2e2 commit e84df8f

4 files changed

Lines changed: 18 additions & 10 deletions

File tree

cmd/erofs-cli/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func run(path string) error {
3030
}
3131
defer func() { _ = f.Close() }()
3232

33-
img, err := erofs.EroFS(f)
33+
img, err := erofs.Open(f)
3434
if err != nil {
3535
return err
3636
}

erofs.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,25 @@ type options struct {
5353
extraDevices []io.ReaderAt
5454
}
5555

56-
// Opt is an option for configuring the EroFS reader
57-
type Opt func(*options)
56+
// OpenOpt is an option for configuring the EROFS reader
57+
type OpenOpt func(*options)
58+
59+
// Deprecated: Use [OpenOpt] instead, will be removed in 0.3
60+
type Opt = OpenOpt
5861

5962
// WithExtraDevices specifies additional devices to read
6063
// chunk data from
61-
func WithExtraDevices(devices ...io.ReaderAt) Opt {
64+
func WithExtraDevices(devices ...io.ReaderAt) OpenOpt {
6265
return func(o *options) {
6366
o.extraDevices = append(o.extraDevices, devices...)
6467
}
6568
}
6669

67-
// EroFS returns a FileSystem reading from the given readerat.
68-
// The readerat must be a valid erofs block file.
70+
// Open returns a FileSystem reading from the given ReaderAt.
71+
// The ReaderAt must be a valid EROFS block file.
6972
// No additional memory mapping is done and must be handled by
7073
// the caller.
71-
func EroFS(r io.ReaderAt, opts ...Opt) (fs.FS, error) {
74+
func Open(r io.ReaderAt, opts ...OpenOpt) (fs.FS, error) {
7275
o := options{}
7376
for _, opt := range opts {
7477
opt(&o)
@@ -149,6 +152,11 @@ func EroFS(r io.ReaderAt, opts ...Opt) (fs.FS, error) {
149152
return &i, nil
150153
}
151154

155+
// Deprecated: Use [Open] instead, will be removed in 0.3
156+
func EroFS(r io.ReaderAt, opts ...Opt) (fs.FS, error) {
157+
return Open(r, opts...)
158+
}
159+
152160
// roundupPowerOfTwo rounds v up to the next power of two.
153161
func roundupPowerOfTwo(v uint32) uint32 {
154162
v--

erofs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func TestErofs(t *testing.T) {
8989
}
9090
}()
9191

92-
_, err = erofs.EroFS(f)
92+
_, err = erofs.Open(f)
9393
if !errors.Is(err, erofs.ErrNotImplemented) {
9494
t.Fatalf("expected ErrNotImplemented, got %v", err)
9595
}

internal/erofstest/testcase.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ func MkfsErofsMaxSize(maxBytes int64, opts ...string) Converter {
100100
}
101101

102102
// openEroFS opens an EROFS image file and returns an fs.FS.
103-
func openEroFS(t testing.TB, path string, opts ...erofs.Opt) fs.FS {
103+
func openEroFS(t testing.TB, path string, opts ...erofs.OpenOpt) fs.FS {
104104
t.Helper()
105105
f, err := os.Open(path)
106106
if err != nil {
107107
t.Fatal(err)
108108
}
109109
t.Cleanup(func() { _ = f.Close() })
110-
efs, err := erofs.EroFS(f, opts...)
110+
efs, err := erofs.Open(f, opts...)
111111
if err != nil {
112112
t.Fatal(err)
113113
}

0 commit comments

Comments
 (0)