Blender V5.3
AppConfig.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "AppConfig.h"
10#include <iostream>
11
14
15using namespace std;
16
17#include "BKE_appdir.hh"
18
20
21Path *Path::_pInstance = nullptr;
23{
24 // get the root directory
25 // soc
26 const std::optional<std::string> path = BKE_appdir_folder_id(blender::BLENDER_SYSTEM_SCRIPTS,
27 nullptr);
29
30 _pInstance = this;
31}
32
33void Path::setRootDir(const string &iRootDir)
34{
35 _ProjectDir = iRootDir + string(DIR_SEP) + "freestyle";
36 _ModelsPath = "";
37 _PatternsPath = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "textures" +
38 string(DIR_SEP) + "variation_patterns" + string(DIR_SEP);
39 _BrushesPath = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "textures" +
40 string(DIR_SEP) + "brushes" + string(DIR_SEP);
41 _EnvMapDir = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "env_map" +
42 string(DIR_SEP);
43 _MapsDir = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "maps" + string(DIR_SEP);
44}
45
46void Path::setHomeDir(const string &iHomeDir)
47{
48 _HomeDir = iHomeDir;
49}
50
52{
53 _pInstance = nullptr;
54}
55
57{
58 return _pInstance;
59}
60
61string Path::getEnvVar(const string &iEnvVarName)
62{
63 string value;
64 if (!getenv(iEnvVarName.c_str())) {
65 cerr << "Warning: You may want to set the $" << iEnvVarName
66 << " environment variable to use Freestyle." << endl
67 << " Otherwise, the current directory will be used instead." << endl;
68 value = ".";
69 }
70 else {
71 value = getenv(iEnvVarName.c_str());
72 }
73 return value;
74}
75
76} // namespace Freestyle::Config
Configuration file.
Configuration definitions.
String utilities.
static string getEnvVar(const string &iEnvVarName)
Definition AppConfig.cpp:61
void setRootDir(const string &iRootDir)
Definition AppConfig.cpp:33
static Path * getInstance()
Definition AppConfig.cpp:56
void setHomeDir(const string &iHomeDir)
Definition AppConfig.cpp:46
static Path * _pInstance
Definition AppConfig.h:27
const char * BKE_appdir_program_dir() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
Definition appdir.cc:1009
@ BLENDER_SYSTEM_SCRIPTS
#define DIR_SEP
Definition path.cpp:29