~kornellapacz/gmnigit

699ac4496f3abb18ea855d31bd2f7b3051621167 — Korneliusz Łapacz 5 months ago 095c093
read symlinks
1 files changed, 14 insertions(+), 0 deletions(-)

M files.go
M files.go => files.go +14 -0
@@ 40,6 40,20 @@ func createDirectoryIndex(treeRootPath, path string) {
		}

		filePath := filepath.Join(treeRootPath, path, file.Name())

		if file.Mode()&os.ModeSymlink != 0 {
			dest, err := os.Readlink(filePath)
			check(err)

			symlink, err := os.Create(filePath + ".txt")
			check(err)
			symlink.WriteString("symlink to: " + dest)

			check(symlink.Close())
			index.WriteString("=> " + file.Name() + ".txt " + file.Name() + "\n")
			continue
		}

		detectedMIME, err := mimetype.DetectFile(filePath)
		check(err)