Skip to content

Commit

Permalink
Added some code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash-Handa committed Sep 29, 2020
1 parent 8af73ba commit ea35721
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 57 deletions.
43 changes: 0 additions & 43 deletions .github/githooks/pre-push

This file was deleted.

2 changes: 1 addition & 1 deletion internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func Bootstrap() {

// if f_V is provided version will be printed and exit(0)
if *f_V {
fmt.Printf("logo-ls %s\nCopyright (c) 2020 Yash Handa\nLicense MIT <https://opensource.org/licenses/MIT>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n", "v1.3.5")
fmt.Printf("logo-ls %s\nCopyright (c) 2020 Yash Handa\nLicense MIT <https://opensource.org/licenses/MIT>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n", "v1.3.6")
fmt.Println("\nWritten by Yash Handa")
os.Exit(sysState.GetExitCode())
}
Expand Down
17 changes: 4 additions & 13 deletions internal/dir/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"path/filepath"
"sort"
"strings"
"syscall"
"time"

"github.com/Yash-Handa/logo-ls/assets"
Expand Down Expand Up @@ -78,9 +77,7 @@ func New(d *os.File) (*dir, error) {
t.info.owner, t.info.group = getOwnerGroupInfo(ds)
}
if api.FlagVector&api.Flag_s > 0 {
if s, ok := ds.Sys().(*syscall.Stat_t); ok {
t.info.blocks = s.Blocks
}
t.info.blocks = getFileBlocks(ds)
}
if api.FlagVector&api.Flag_i == 0 {
t.info.icon = assets.Icon_Def["diropen"].GetGlyph()
Expand Down Expand Up @@ -115,9 +112,7 @@ func New(d *os.File) (*dir, error) {
f.owner, f.group = getOwnerGroupInfo(v)
}
if api.FlagVector&api.Flag_s > 0 {
if s, ok := v.Sys().(*syscall.Stat_t); ok {
f.blocks = s.Blocks
}
f.blocks = getFileBlocks(v)
}

if api.FlagVector&api.Flag_i == 0 {
Expand Down Expand Up @@ -165,9 +160,7 @@ func New(d *os.File) (*dir, error) {
t.parent.owner, t.parent.group = getOwnerGroupInfo(pds)
}
if api.FlagVector&api.Flag_s > 0 {
if s, ok := pds.Sys().(*syscall.Stat_t); ok {
t.parent.blocks = s.Blocks
}
t.parent.blocks = getFileBlocks(pds)
}
if api.FlagVector&api.Flag_i == 0 {
t.parent.icon = assets.Icon_Def["diropen"].GetGlyph()
Expand Down Expand Up @@ -202,9 +195,7 @@ func New_ArgFiles(files []os.FileInfo) *dir {
f.owner, f.group = getOwnerGroupInfo(v)
}
if api.FlagVector&api.Flag_s > 0 {
if s, ok := v.Sys().(*syscall.Stat_t); ok {
f.blocks = s.Blocks
}
f.blocks = getFileBlocks(v)
}
if api.FlagVector&api.Flag_i == 0 {
f.icon, f.iconColor = getIcon(f.name, f.ext, f.indicator)
Expand Down
7 changes: 7 additions & 0 deletions internal/dir/formatterStuff.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ func getOwnerGroupInfo(fi os.FileInfo) (o string, g string) {
return
}

func getFileBlocks(fi os.FileInfo) int64 {
if s, ok := fi.Sys().(*syscall.Stat_t); ok {
return s.Blocks
}
return 0
}

// get indicator of the file
func getIndicator(modebit os.FileMode) (i string) {
switch {
Expand Down
Binary file modified logo-ls.1.gz
Binary file not shown.

0 comments on commit ea35721

Please sign in to comment.