code.gitea.io/gitea@v1.19.3/modules/options/dynamic.go (about) 1 // Copyright 2016 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 //go:build !bindata 5 6 package options 7 8 import ( 9 "code.gitea.io/gitea/modules/setting" 10 ) 11 12 // Dir returns all files from static or custom directory. 13 func Dir(name string) ([]string, error) { 14 if directories.Filled(name) { 15 return directories.Get(name), nil 16 } 17 18 result, err := listLocalDirIfExist([]string{setting.CustomPath, setting.StaticRootPath}, "options", name) 19 if err != nil { 20 return nil, err 21 } 22 23 return directories.AddAndGet(name, result), nil 24 } 25 26 // fileFromOptionsDir is a helper to read files from custom or static path. 27 func fileFromOptionsDir(elems ...string) ([]byte, error) { 28 return readLocalFile([]string{setting.CustomPath, setting.StaticRootPath}, "options", elems...) 29 } 30 31 // IsDynamic will return false when using embedded data (-tags bindata) 32 func IsDynamic() bool { 33 return true 34 }