mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
#7896: LyX templates folder is empty - create a symlink to system templates in user template directory at run time
This commit is contained in:
parent
bfc7c4d379
commit
e4fada8c57
42
src/LyX.cpp
42
src/LyX.cpp
@ -779,6 +779,43 @@ void cleanDuplicateEnvVars()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static void initTemplatePath()
|
||||||
|
{
|
||||||
|
FileName const package_template_path =
|
||||||
|
FileName(addPath(package().system_support().absFileName(), "templates"));
|
||||||
|
|
||||||
|
if (lyxrc.template_path.empty()) {
|
||||||
|
lyxrc.template_path = package_template_path.absFileName();
|
||||||
|
}
|
||||||
|
#if defined (USE_MACOSX_PACKAGING)
|
||||||
|
FileName const user_template_path =
|
||||||
|
FileName(addPath(package().user_support().absFileName(), "templates"));
|
||||||
|
|
||||||
|
if (package_template_path != FileName(lyxrc.template_path) &&
|
||||||
|
user_template_path != FileName(lyxrc.template_path))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/// addPath cannot be used here.
|
||||||
|
/// The path with trailing slash doesn't work as symlink name.
|
||||||
|
FileName const user_template_link =
|
||||||
|
FileName(user_template_path.absFileName() + "SystemTemplates");
|
||||||
|
if (user_template_link.isSymLink()) {
|
||||||
|
user_template_link.removeFile();
|
||||||
|
}
|
||||||
|
if (!user_template_link.exists()) {
|
||||||
|
if (!package_template_path.link(user_template_link)) {
|
||||||
|
LYXERR(Debug::INIT, "Cannot create symlink " + user_template_link.absFileName());
|
||||||
|
lyxrc.template_path = package_template_path.absFileName();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lyxrc.template_path = user_template_path.absFileName();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LyX::init()
|
bool LyX::init()
|
||||||
{
|
{
|
||||||
#ifdef SIGHUP
|
#ifdef SIGHUP
|
||||||
@ -801,10 +838,7 @@ bool LyX::init()
|
|||||||
lyxrc.example_path = addPath(package().system_support().absFileName(),
|
lyxrc.example_path = addPath(package().system_support().absFileName(),
|
||||||
"examples");
|
"examples");
|
||||||
}
|
}
|
||||||
if (lyxrc.template_path.empty()) {
|
initTemplatePath();
|
||||||
lyxrc.template_path = addPath(package().system_support().absFileName(),
|
|
||||||
"templates");
|
|
||||||
}
|
|
||||||
|
|
||||||
// init LyXDir environment variable
|
// init LyXDir environment variable
|
||||||
string const lyx_dir = package().lyx_dir().absFileName();
|
string const lyx_dir = package().lyx_dir().absFileName();
|
||||||
|
Loading…
Reference in New Issue
Block a user