mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-29 07:00:31 +03:00
Add support for symbolic links for content, layout, static, theme
Note: This is for the content roots only, but that should satisfy most needs. Fixes #1855
This commit is contained in:
parent
6258d48b02
commit
e5aa477491
4 changed files with 33 additions and 9 deletions
|
@ -428,6 +428,24 @@ func FindCWD() (string, error) {
|
|||
return path, nil
|
||||
}
|
||||
|
||||
// SymbolicWalk is like filepath.Walk, but it supports the root being a
|
||||
// symbolic link. It will still not follow symbolic links deeper down in
|
||||
// the file structure
|
||||
func SymbolicWalk(fs afero.Fs, root string, walker filepath.WalkFunc) error {
|
||||
rootContent, err := afero.ReadDir(fs, root)
|
||||
|
||||
if err != nil {
|
||||
return walker(root, nil, err)
|
||||
}
|
||||
|
||||
for _, fi := range rootContent {
|
||||
afero.Walk(fs, filepath.Join(root, fi.Name()), walker)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
// Same as WriteToDisk but checks to see if file/directory already exists.
|
||||
func SafeWriteToDisk(inpath string, r io.Reader, fs afero.Fs) (err error) {
|
||||
return afero.SafeWriteReader(fs, inpath, r)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue