X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=dirlist.go;h=ab631bb9a7d5b919b7f553678f1744929327ff0d;hb=e5b6a66ac9e02d1369f72bc2b1b3fac3de36ef22;hp=c7c7e6ab3fd320f4063e911347570a3a186934d3;hpb=a65ca9f1e9917d3c8193297ce20b59352a009c55;p=godlighty.git diff --git a/dirlist.go b/dirlist.go index c7c7e6a..ab631bb 100644 --- a/dirlist.go +++ b/dirlist.go @@ -1,6 +1,6 @@ /* godlighty -- highly-customizable HTTP, HTTP/2, HTTPS server -Copyright (C) 2021 Sergey Matveev +Copyright (C) 2021-2023 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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-")