]> Sergey Matveev's repositories - godlighty.git/blobdiff - dirlist.go
Show symbolic link values
[godlighty.git] / dirlist.go
index 82b360650175b46ee7a1f5cc9e5caedd649219c2..49976a3b83585df5e8078ef54373353adde52d20 100644 (file)
@@ -22,6 +22,7 @@ import (
        "html/template"
        "io/fs"
        "os"
+       "path"
        "sort"
        "time"
 
@@ -57,11 +58,12 @@ type DirListFile struct {
        IsDir   bool
        Type    string
        ModTime string
+       Symlink string
 }
 
 func dirList(
        cfg *HostCfg,
-       dir string,
+       dir, pth string,
        entries []os.DirEntry,
        readme string,
 ) (*os.File, error) {
@@ -83,6 +85,9 @@ func dirList(
                } else {
                        file.Type = mediaType(file.Name, cfg.MIMEs)
                }
+               if (entry.Type() & fs.ModeSymlink) > 0 {
+                       file.Symlink, _ = os.Readlink(path.Join(pth, fi.Name()))
+               }
                files = append(files, file)
        }
        fd, err := os.CreateTemp("", "godlist-dirlist-")