2016-12-22 13:12:23 -05:00
|
|
|
// Copyright 2016 The Gitea Authors. All rights reserved.
|
2022-11-27 13:20:29 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2016-12-22 13:12:23 -05:00
|
|
|
|
2021-08-24 11:47:09 -05:00
|
|
|
//go:build !bindata
|
|
|
|
|
2016-12-22 13:12:23 -05:00
|
|
|
package options
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Dir returns all files from static or custom directory.
|
|
|
|
func Dir(name string) ([]string, error) {
|
|
|
|
if directories.Filled(name) {
|
|
|
|
return directories.Get(name), nil
|
|
|
|
}
|
|
|
|
|
2023-03-22 06:56:20 -05:00
|
|
|
result, err := listLocalDirIfExist([]string{setting.CustomPath, setting.StaticRootPath}, "options", name)
|
2020-11-27 21:42:08 -05:00
|
|
|
if err != nil {
|
2023-03-22 06:56:20 -05:00
|
|
|
return nil, err
|
2016-12-22 13:12:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return directories.AddAndGet(name, result), nil
|
|
|
|
}
|
|
|
|
|
2023-03-22 06:56:20 -05:00
|
|
|
// fileFromOptionsDir is a helper to read files from custom or static path.
|
|
|
|
func fileFromOptionsDir(elems ...string) ([]byte, error) {
|
|
|
|
return readLocalFile([]string{setting.CustomPath, setting.StaticRootPath}, "options", elems...)
|
2016-12-22 13:12:23 -05:00
|
|
|
}
|
2020-01-29 21:00:27 -05:00
|
|
|
|
|
|
|
// IsDynamic will return false when using embedded data (-tags bindata)
|
|
|
|
func IsDynamic() bool {
|
|
|
|
return true
|
|
|
|
}
|