2016-12-22 23:42:23 +05:30
|
|
|
// Copyright 2016 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2016-12-22 23:42:23 +05:30
|
|
|
|
2021-08-24 22:17:09 +05:30
|
|
|
//go:build !bindata
|
|
|
|
|
2016-12-22 23:42:23 +05:30
|
|
|
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 01:32:49 +05:30
|
|
|
result, err := listLocalDirIfExist([]string{setting.CustomPath, setting.StaticRootPath}, "options", name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2016-12-22 23:42:23 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return directories.AddAndGet(name, result), nil
|
|
|
|
}
|
|
|
|
|
2023-03-22 01:32:49 +05:30
|
|
|
// 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 23:42:23 +05:30
|
|
|
}
|
2020-01-30 07:30:27 +05:30
|
|
|
|
|
|
|
// IsDynamic will return false when using embedded data (-tags bindata)
|
|
|
|
func IsDynamic() bool {
|
|
|
|
return true
|
|
|
|
}
|