|
|
|
@ -155,7 +155,7 @@ type DirectorySection struct {
|
|
|
|
|
|
|
|
|
|
// RenderAndWrite scans and renders a list of the contents of a directory (skipping hidden or restricted files)
|
|
|
|
|
func (s *DirectorySection) RenderAndWrite(client *core.Client) *errors.Error {
|
|
|
|
|
fd, err := core.OpenFile(s.path)
|
|
|
|
|
file, err := core.OpenFile(s.path)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -164,7 +164,7 @@ func (s *DirectorySection) RenderAndWrite(client *core.Client) *errors.Error {
|
|
|
|
|
dirContents := make([]byte, 0)
|
|
|
|
|
|
|
|
|
|
// Scan directory and build lines
|
|
|
|
|
err = core.ScanDirectory(fd, s.path, func(file os.FileInfo, p *core.Path) {
|
|
|
|
|
err = core.ScanDirectory(file, s.path, func(file os.FileInfo, p *core.Path) {
|
|
|
|
|
// Ignore hidden files!
|
|
|
|
|
_, ok := s.hidden[file.Name()]
|
|
|
|
|
if ok {
|
|
|
|
@ -190,7 +190,7 @@ type FileSection struct {
|
|
|
|
|
// RenderAndWrite simply opens, reads and writes the file contents to the client
|
|
|
|
|
func (s *FileSection) RenderAndWrite(client *core.Client) *errors.Error {
|
|
|
|
|
// Open FD for the file
|
|
|
|
|
fd, err := core.OpenFile(s.path)
|
|
|
|
|
file, err := core.OpenFile(s.path)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -200,7 +200,7 @@ func (s *FileSection) RenderAndWrite(client *core.Client) *errors.Error {
|
|
|
|
|
|
|
|
|
|
// Scan the file contents, format for gophermap, append to byte slice
|
|
|
|
|
err = core.ScanFile(
|
|
|
|
|
fd,
|
|
|
|
|
file,
|
|
|
|
|
func(line string) bool {
|
|
|
|
|
b = append(b, buildInfoLine(line)...)
|
|
|
|
|
return true
|
|
|
|
@ -222,13 +222,13 @@ type SubgophermapSection struct {
|
|
|
|
|
// RenderAndWrite reads, renders and writes the contents of the gophermap to the client
|
|
|
|
|
func (s *SubgophermapSection) RenderAndWrite(client *core.Client) *errors.Error {
|
|
|
|
|
// Get FD for gophermap
|
|
|
|
|
fd, err := core.OpenFile(s.path)
|
|
|
|
|
file, err := core.OpenFile(s.path)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read gophermap into sections
|
|
|
|
|
sections, err := readGophermap(fd, s.path)
|
|
|
|
|
sections, err := readGophermap(file, s.path)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|