Return mode_bits when listing files in a directory

This commit is contained in:
Matthew Penner 2020-11-29 14:20:24 -07:00
parent 169e8b8f8b
commit 068f41393d

View File

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"github.com/gabriel-vasile/mimetype" "github.com/gabriel-vasile/mimetype"
"os" "os"
"strconv"
"time" "time"
) )
@ -18,6 +19,7 @@ func (s *Stat) MarshalJSON() ([]byte, error) {
Created string `json:"created"` Created string `json:"created"`
Modified string `json:"modified"` Modified string `json:"modified"`
Mode string `json:"mode"` Mode string `json:"mode"`
ModeBits string `json:"mode_bits"`
Size int64 `json:"size"` Size int64 `json:"size"`
Directory bool `json:"directory"` Directory bool `json:"directory"`
File bool `json:"file"` File bool `json:"file"`
@ -28,6 +30,7 @@ func (s *Stat) MarshalJSON() ([]byte, error) {
Created: s.CTime().Format(time.RFC3339), Created: s.CTime().Format(time.RFC3339),
Modified: s.Info.ModTime().Format(time.RFC3339), Modified: s.Info.ModTime().Format(time.RFC3339),
Mode: s.Info.Mode().String(), Mode: s.Info.Mode().String(),
ModeBits: strconv.FormatUint(uint64(s.Info.Mode()), 8),
Size: s.Info.Size(), Size: s.Info.Size(),
Directory: s.Info.IsDir(), Directory: s.Info.IsDir(),
File: !s.Info.IsDir(), File: !s.Info.IsDir(),