Skip to content

Commit

Permalink
Rewrite gitfs and bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkKremer committed Aug 27, 2024
1 parent a9c1cbe commit 5a5ee4b
Show file tree
Hide file tree
Showing 10 changed files with 428 additions and 496 deletions.
333 changes: 158 additions & 175 deletions bundler.go

Large diffs are not rendered by default.

149 changes: 0 additions & 149 deletions internal/gitfs/dir.go

This file was deleted.

21 changes: 10 additions & 11 deletions internal/gitfs/direntry.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,26 @@ import (
)

type GitDirEntry struct {
fs *GitFs
path string
typ fs.FileMode
filesys *GitFs
i int
}

func (g *GitDirEntry) Name() string {
return filepath.Base(g.path)
return filepath.Base(g.info().path)
}

func (g *GitDirEntry) IsDir() bool {
return g.typ.IsDir()
return g.info().isDir
}

func (g *GitDirEntry) Type() fs.FileMode {
return g.typ
return g.info().mode.Type()
}

func (g *GitDirEntry) Info() (fs.FileInfo, error) {
f, err := g.fs.Open(g.path)
if err != nil {
return nil, err
}
return f.Stat()
return g.filesys.openPos(g.i).Stat()
}

func (g *GitDirEntry) info() *fileInfo {
return &g.filesys.paths[g.i]
}
84 changes: 0 additions & 84 deletions internal/gitfs/file.go

This file was deleted.

42 changes: 42 additions & 0 deletions internal/gitfs/fileinfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package gitfs

import (
"io/fs"
"path/filepath"
"time"
)

type GitFileInfo struct {
filesys *GitFs
i int
size int64
modTime time.Time
}

func (g *GitFileInfo) Name() string {
return filepath.Base(g.info().path)
}

func (g *GitFileInfo) Size() int64 {
return g.size
}

func (g *GitFileInfo) Mode() fs.FileMode {
return g.info().mode
}

func (g *GitFileInfo) ModTime() time.Time {
return g.modTime
}

func (g *GitFileInfo) IsDir() bool {
return g.info().isDir
}

func (g *GitFileInfo) Sys() any {
return g
}

func (g *GitFileInfo) info() *fileInfo {
return &g.filesys.paths[g.i]
}
Loading

0 comments on commit 5a5ee4b

Please sign in to comment.