2020-08-12 13:16:25 +02:00
|
|
|
package config
|
|
|
|
|
2022-03-02 12:20:02 +01:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
2022-04-06 17:46:41 +02:00
|
|
|
// RawEnabled checks if indexing and conversion of RAW files is enabled.
|
|
|
|
func (c *Config) RawEnabled() bool {
|
|
|
|
return !c.DisableRaw()
|
|
|
|
}
|
|
|
|
|
|
|
|
// RawPresets checks if RAW converter presents should be used (may reduce performance).
|
2021-05-01 10:25:34 +02:00
|
|
|
func (c *Config) RawPresets() bool {
|
|
|
|
return c.options.RawPresets
|
2021-04-30 14:24:01 +02:00
|
|
|
}
|
|
|
|
|
2020-08-12 13:16:25 +02:00
|
|
|
// DarktableBin returns the darktable-cli executable file name.
|
|
|
|
func (c *Config) DarktableBin() string {
|
2020-12-18 20:42:12 +01:00
|
|
|
return findExecutable(c.options.DarktableBin, "darktable-cli")
|
2020-08-12 13:16:25 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 15:33:46 +02:00
|
|
|
// DarktableBlacklist returns the darktable file extension blacklist.
|
|
|
|
func (c *Config) DarktableBlacklist() string {
|
|
|
|
return c.options.DarktableBlacklist
|
|
|
|
}
|
|
|
|
|
2022-03-02 12:20:02 +01:00
|
|
|
// DarktableConfigPath returns the darktable config directory.
|
|
|
|
func (c *Config) DarktableConfigPath() string {
|
2022-04-06 17:46:41 +02:00
|
|
|
if c.options.DarktableConfigPath != "" {
|
|
|
|
return c.options.DarktableConfigPath
|
2022-03-02 12:20:02 +01:00
|
|
|
}
|
2022-04-06 17:46:41 +02:00
|
|
|
|
|
|
|
return filepath.Join(c.ConfigPath(), "darktable")
|
2022-03-02 12:20:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// DarktableCachePath returns the darktable cache directory.
|
|
|
|
func (c *Config) DarktableCachePath() string {
|
2022-04-06 17:46:41 +02:00
|
|
|
if c.options.DarktableCachePath != "" {
|
|
|
|
return c.options.DarktableCachePath
|
|
|
|
}
|
|
|
|
|
|
|
|
return filepath.Join(c.CachePath(), "darktable")
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateDarktableCachePath creates and returns the darktable cache directory.
|
|
|
|
func (c *Config) CreateDarktableCachePath() (string, error) {
|
|
|
|
cachePath := c.DarktableCachePath()
|
|
|
|
|
|
|
|
if err := os.MkdirAll(cachePath, os.ModePerm); err != nil {
|
|
|
|
return cachePath, err
|
|
|
|
} else {
|
|
|
|
c.options.DarktableCachePath = cachePath
|
|
|
|
}
|
|
|
|
|
|
|
|
return cachePath, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateDarktableConfigPath creates and returns the darktable config directory.
|
|
|
|
func (c *Config) CreateDarktableConfigPath() (string, error) {
|
|
|
|
configPath := c.DarktableConfigPath()
|
2022-03-02 12:20:02 +01:00
|
|
|
|
2022-04-06 17:46:41 +02:00
|
|
|
if err := os.MkdirAll(configPath, os.ModePerm); err != nil {
|
|
|
|
return configPath, err
|
|
|
|
} else {
|
|
|
|
c.options.DarktableConfigPath = configPath
|
2022-03-02 12:20:02 +01:00
|
|
|
}
|
|
|
|
|
2022-04-06 17:46:41 +02:00
|
|
|
return configPath, nil
|
2022-03-02 12:20:02 +01:00
|
|
|
}
|
|
|
|
|
2022-04-06 17:46:41 +02:00
|
|
|
// DarktableEnabled checks if Darktable is enabled for RAW conversion.
|
2021-04-30 14:24:01 +02:00
|
|
|
func (c *Config) DarktableEnabled() bool {
|
|
|
|
return !c.DisableDarktable()
|
|
|
|
}
|
|
|
|
|
2021-05-01 10:25:34 +02:00
|
|
|
// RawtherapeeBin returns the rawtherapee-cli executable file name.
|
|
|
|
func (c *Config) RawtherapeeBin() string {
|
|
|
|
return findExecutable(c.options.RawtherapeeBin, "rawtherapee-cli")
|
|
|
|
}
|
|
|
|
|
2021-09-21 15:33:46 +02:00
|
|
|
// RawtherapeeBlacklist returns the RawTherapee file extension blacklist.
|
|
|
|
func (c *Config) RawtherapeeBlacklist() string {
|
|
|
|
return c.options.RawtherapeeBlacklist
|
|
|
|
}
|
|
|
|
|
2022-04-06 17:46:41 +02:00
|
|
|
// RawtherapeeEnabled checks if Rawtherapee is enabled for RAW conversion.
|
2021-05-01 10:25:34 +02:00
|
|
|
func (c *Config) RawtherapeeEnabled() bool {
|
|
|
|
return !c.DisableRawtherapee()
|
2020-08-12 13:16:25 +02:00
|
|
|
}
|
|
|
|
|
2022-04-06 17:46:41 +02:00
|
|
|
// SipsEnabled checks if SIPS is enabled for RAW conversion.
|
2021-04-30 14:24:01 +02:00
|
|
|
func (c *Config) SipsEnabled() bool {
|
|
|
|
return !c.DisableSips()
|
|
|
|
}
|
|
|
|
|
|
|
|
// SipsBin returns the SIPS executable file name.
|
2020-08-12 13:16:25 +02:00
|
|
|
func (c *Config) SipsBin() string {
|
2020-12-18 20:42:12 +01:00
|
|
|
return findExecutable(c.options.SipsBin, "sips")
|
2020-08-12 13:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// HeifConvertBin returns the heif-convert executable file name.
|
|
|
|
func (c *Config) HeifConvertBin() string {
|
2020-12-18 20:42:12 +01:00
|
|
|
return findExecutable(c.options.HeifConvertBin, "heif-convert")
|
2020-08-12 13:16:25 +02:00
|
|
|
}
|
2021-04-30 14:24:01 +02:00
|
|
|
|
2022-04-06 17:46:41 +02:00
|
|
|
// HeifConvertEnabled checks if heif-convert is enabled for HEIF conversion.
|
2021-04-30 14:24:01 +02:00
|
|
|
func (c *Config) HeifConvertEnabled() bool {
|
|
|
|
return !c.DisableHeifConvert()
|
|
|
|
}
|