]> git.lyx.org Git - lyx.git/blob - src/support/Package.cpp
c0a84e9a1150d05fc31f07d7db1dd21155fb1d34
[lyx.git] / src / support / Package.cpp
1 // -*- C++ -*-
2 /**
3  * \file package.cpp
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "support/Package.h"
15
16 #include "support/debug.h"
17 #include "support/environment.h"
18 #include "support/ExceptionMessage.h"
19 #include "support/filetools.h"
20 #include "support/gettext.h"
21 #include "support/lstrings.h"
22 #include "support/os.h"
23
24 #if defined (USE_WINDOWS_PACKAGING)
25 # include "support/os_win32.h"
26 #endif
27
28
29 #include <list>
30
31 #if !defined (USE_WINDOWS_PACKAGING) && \
32     !defined (USE_MACOSX_PACKAGING) && \
33     !defined (USE_POSIX_PACKAGING)
34 #error USE_FOO_PACKAGING must be defined for FOO = WINDOWS, MACOSX or POSIX.
35 #endif
36
37 #if defined (USE_MACOSX_PACKAGING)
38 # include <CoreServices/CoreServices.h> // FSFindFolder, FSRefMakePath
39 #endif
40
41 using namespace std;
42
43 namespace lyx {
44 namespace support {
45
46 namespace {
47
48 Package package_;
49 bool initialised_ = false;
50
51 } // namespace anon
52
53
54 void init_package(string const & command_line_arg0,
55                   string const & command_line_system_support_dir,
56                   string const & command_line_user_support_dir,
57                   exe_build_dir_to_top_build_dir top_build_dir_location)
58 {
59         // Can do so only once.
60         if (initialised_)
61                 return;
62
63         package_ = Package(command_line_arg0,
64                            command_line_system_support_dir,
65                            command_line_user_support_dir,
66                            top_build_dir_location);
67         initialised_ = true;
68 }
69
70
71 Package const & package()
72 {
73         // Commented out because package().locale_dir() can be called
74         // from the message translation code in Messages.cpp before
75         // init_package() is called. Lars is on the case...
76         // LASSERT(initialised_, /**/);
77         return package_;
78 }
79
80
81 namespace {
82
83 FileName const abs_path_from_binary_name(string const & exe);
84
85 void buildDirs(FileName const & abs_binary,
86         exe_build_dir_to_top_build_dir top_build_dir_location,
87         FileName &, FileName &);
88
89 FileName const get_document_dir(FileName const & home_dir);
90
91 FileName const get_home_dir();
92
93 FileName const get_locale_dir(FileName const & system_support_dir);
94
95 FileName const get_system_support_dir(FileName const & abs_binary,
96                                     string const & command_line_system_support_dir);
97
98 FileName const get_temp_dir();
99
100 FileName const get_default_user_support_dir(FileName const & home_dir);
101
102 bool userSupportDir(FileName const & default_user_support_dir,
103                      string const & command_line_user_support_dir, FileName & result);
104
105
106 string const & with_version_suffix();
107
108 } // namespace anon
109
110
111 Package::Package(string const & command_line_arg0,
112                  string const & command_line_system_support_dir,
113                  string const & command_line_user_support_dir,
114                  exe_build_dir_to_top_build_dir top_build_dir_location)
115         : explicit_user_support_dir_(false)
116 {
117         home_dir_ = get_home_dir();
118         system_temp_dir_ = get_temp_dir();
119         temp_dir_ = system_temp_dir_;
120         document_dir_ = get_document_dir(home_dir_);
121
122         FileName const abs_binary = abs_path_from_binary_name(command_line_arg0);
123         string const bdir = onlyPath(abs_binary.absFilename());
124         // We may be using libtools
125         if (suffixIs(bdir, ".libs/"))
126                 binary_dir_ = FileName(addPath(bdir, "../"));
127         else
128                 binary_dir_ = FileName(bdir);
129
130         // Is LyX being run in-place from the build tree?
131         buildDirs(abs_binary, top_build_dir_location,
132                 build_support_dir_, system_support_dir_);
133
134         if (build_support_dir_.empty())
135                 system_support_dir_ =
136                         get_system_support_dir(abs_binary,
137                                                command_line_system_support_dir);
138
139         locale_dir_ = get_locale_dir(system_support_dir_);
140
141         FileName const default_user_support_dir =
142                 get_default_user_support_dir(home_dir_);
143
144         explicit_user_support_dir_ = userSupportDir(default_user_support_dir,
145                                      command_line_user_support_dir, user_support_dir_);
146
147         FileName const configure_script(addName(system_support().absFilename(), "configure.py"));
148         configure_command_ = os::python() + ' ' +
149                         quoteName(configure_script.toFilesystemEncoding()) +
150                         with_version_suffix();
151
152         LYXERR(Debug::INIT, "<package>\n"
153                 << "\tbinary_dir " << binary_dir().absFilename() << '\n'
154                 << "\tsystem_support " << system_support().absFilename() << '\n'
155                 << "\tbuild_support " << build_support().absFilename() << '\n'
156                 << "\tuser_support " << user_support().absFilename() << '\n'
157                 << "\tlocale_dir " << locale_dir().absFilename() << '\n'
158                 << "\tdocument_dir " << document_dir().absFilename() << '\n'
159                 << "\ttemp_dir " << temp_dir().absFilename() << '\n'
160                 << "\thome_dir " << home_dir().absFilename() << '\n'
161                 << "</package>\n");
162 }
163
164
165 void Package::set_temp_dir(FileName const & temp_dir) const
166 {
167         if (temp_dir.empty())
168                 temp_dir_ = system_temp_dir_;
169         else
170                 temp_dir_ = temp_dir;
171 }
172
173
174 namespace {
175
176 // These next functions contain the stuff that is substituted at
177 // configuration-time.
178 FileName const hardcoded_localedir()
179 {
180         // FIXME UNICODE
181         // The build system needs to make sure that this is in utf8 encoding.
182         return FileName(LYX_ABS_INSTALLED_LOCALEDIR);
183 }
184
185
186 FileName const hardcoded_system_support_dir()
187 {
188         // FIXME UNICODE
189         // The build system needs to make sure that this is in utf8 encoding.
190         return FileName(LYX_ABS_INSTALLED_DATADIR);
191 }
192
193
194 string const & with_version_suffix()
195 {
196         static string const program_suffix = PROGRAM_SUFFIX;
197         static string const with_version_suffix =
198                 " --with-version-suffix=" PROGRAM_SUFFIX;
199         return program_suffix.empty() ? program_suffix : with_version_suffix;
200 }
201
202 } // namespace anon
203
204
205 FileName const & Package::top_srcdir()
206 {
207         // FIXME UNICODE
208         // The build system needs to make sure that this is in utf8 encoding.
209         static FileName const dir(LYX_ABS_TOP_SRCDIR);
210         return dir;
211 }
212
213
214 namespace {
215
216 bool check_command_line_dir(string const & dir,
217                             string const & file,
218                             string const & command_line_switch);
219
220 FileName const extract_env_var_dir(string const & env_var);
221
222 bool check_env_var_dir(FileName const & dir,
223                        string const & env_var);
224
225 bool check_env_var_dir(FileName const & dir,
226                        string const & file,
227                        string const & env_var);
228
229 string const relative_locale_dir();
230
231 string const relative_system_support_dir();
232
233
234 /**
235  * Convert \p name to internal path and strip a trailing slash, since it
236  * comes from user input (commandline or environment).
237  * \p name is encoded in utf8.
238  */
239 string const fix_dir_name(string const & name)
240 {
241         return rtrim(os::internal_path(name), "/");
242 }
243
244
245 FileName buildSupportDir(string const & binary_dir,
246                       exe_build_dir_to_top_build_dir top_build_dir_location)
247 {
248         string indirection;
249         switch (top_build_dir_location) {
250         case top_build_dir_is_one_level_up:
251                 indirection = "../lib";
252                 break;
253         case top_build_dir_is_two_levels_up:
254                 indirection = "../../lib";
255                 break;
256         }
257         return FileName(addPath(binary_dir, indirection));
258 }
259
260
261 void buildDirs(FileName const & abs_binary,
262   exe_build_dir_to_top_build_dir top_build_dir_location,
263         FileName & build_support_dir, FileName & system_support_dir)
264 {
265         string const check_text = "Checking whether LyX is run in place...";
266
267         // We're looking for "Makefile" in a directory
268         //   binary_dir/../lib
269         // We're also looking for "chkconfig.ltx" in a directory
270         //   top_srcdir()/lib
271         // If both are found, then we're running LyX in-place.
272
273         // Note that the name of the lyx binary may be a symbolic link.
274         // If that is the case, then we follow the links too.
275         FileName binary = abs_binary;
276         while (true) {
277                 // Try and find "lyxrc.defaults".
278                 string binary_dir = onlyPath(binary.absFilename());
279                 // We may be using libtools with static linking.
280                 if (suffixIs(binary_dir, ".libs/"))
281                         binary_dir = addPath(binary_dir, "../");
282                 build_support_dir = buildSupportDir(binary_dir, top_build_dir_location);
283                 if (!fileSearch(build_support_dir.absFilename(), "Makefile").empty()) {
284                         // Try and find "chkconfig.ltx".
285                         system_support_dir =
286                                 FileName(addPath(Package::top_srcdir().absFilename(), "lib"));
287
288                         if (!fileSearch(system_support_dir.absFilename(), "chkconfig.ltx").empty()) {
289                                 LYXERR(Debug::INIT, check_text << " yes");
290                                 return;
291                         }
292                 }
293
294                 // Check whether binary is a symbolic link.
295                 // If so, resolve it and repeat the exercise.
296                 if (!binary.isSymLink())
297                         break;
298
299                 FileName link;
300                 if (readLink(binary, link)) {
301                         binary = link;
302                 } else {
303                         // Unable to resolve the link.
304                         break;
305                 }
306         }
307
308         LYXERR(Debug::INIT, check_text << " no");
309         system_support_dir = FileName();
310         build_support_dir = FileName();
311 }
312
313
314 // Specification of document_dir_ may be reset by LyXRC,
315 // but the default is fixed for a given OS.
316 FileName const get_document_dir(FileName const & home_dir)
317 {
318 #if defined (USE_WINDOWS_PACKAGING)
319         (void)home_dir; // Silence warning about unused variable.
320         os::GetFolderPath win32_folder_path;
321         return FileName(win32_folder_path(os::GetFolderPath::PERSONAL));
322 #else // Posix-like.
323         return home_dir;
324 #endif
325 }
326
327
328 // The specification of home_dir_ is fixed for a given OS.
329 // A typical example on Windows: "C:/Documents and Settings/USERNAME"
330 // and on a Posix-like machine: "/home/USERNAME".
331 FileName const get_home_dir()
332 {
333 #if defined (USE_WINDOWS_PACKAGING)
334         string const home_dir = getEnv("USERPROFILE");
335 #else // Posix-like.
336         string const home_dir = getEnv("HOME");
337 #endif
338
339         return FileName(fix_dir_name(home_dir));
340 }
341
342
343 // Several sources are probed to ascertain the locale directory.
344 // The only requirement is that the result is indeed a directory.
345 FileName const get_locale_dir(FileName const & system_support_dir)
346 {
347         // 1. Use the "LYX_LOCALEDIR" environment variable.
348         FileName const path_env = extract_env_var_dir("LYX_LOCALEDIR");
349         if (!path_env.empty() && check_env_var_dir(path_env, "LYX_LOCALEDIR"))
350                 return path_env;
351
352         // 2. Search for system_support_dir / <relative locale dir>
353         // The <relative locale dir> is OS-dependent. (On Unix, it will
354         // be "../locale/".)
355         FileName path(addPath(system_support_dir.absFilename(),
356                 relative_locale_dir()));
357
358         if (path.exists() && path.isDirectory())
359                 return path;
360
361         // 3. Fall back to the hard-coded LOCALEDIR.
362         path = hardcoded_localedir();
363         if (path.exists() && path.isDirectory())
364                 return path;
365
366         return FileName();
367 }
368
369
370 // Specification of temp_dir_ may be reset by LyXRC,
371 // but the default is fixed for a given OS.
372 FileName const get_temp_dir()
373 {
374 #if defined (USE_WINDOWS_PACKAGING)
375         // Typical example: C:/TEMP/.
376         char path[MAX_PATH];
377         GetTempPath(MAX_PATH, path);
378         // Remove trailing backslash if any.
379         return FileName(rtrim(to_utf8(from_local8bit(path)), "\\"));
380 #else // Posix-like.
381         return FileName("/tmp");
382 #endif
383 }
384
385
386 // Extracts the absolute path from the foo of "-sysdir foo" or "-userdir foo"
387 FileName const abs_path_from_command_line(string const & command_line)
388 {
389         if (command_line.empty())
390                 return FileName();
391
392         string const str_path = fix_dir_name(command_line);
393         FileName path(str_path);
394         return path.isAbsolute() ? path : makeAbsPath(str_path);
395 }
396
397
398 // Does the grunt work for abs_path_from_binary_name()
399 FileName const get_binary_path(string const & exe)
400 {
401 #if defined (USE_WINDOWS_PACKAGING)
402         // The executable may have been invoked either with or
403         // without the .exe extension.
404         // Ensure that it is present.
405         string const as_internal_path = os::internal_path(exe);
406         string const exe_path = suffixIs(as_internal_path, ".exe") ?
407                 as_internal_path : as_internal_path + ".exe";
408 #else
409         string const exe_path = os::internal_path(exe);
410 #endif
411         FileName exepath(exe_path);
412         if (exepath.isAbsolute())
413                 return exepath;
414
415         // Two possibilities present themselves.
416         // 1. The binary is relative to the CWD.
417         FileName const abs_exe_path = makeAbsPath(exe_path);
418         if (abs_exe_path.exists())
419                 return abs_exe_path;
420
421         // 2. exe must be the name of the binary only and it
422         // can be found on the PATH.
423         string const exe_name = onlyFilename(exe_path);
424         if (exe_name != exe_path)
425                 return FileName();
426
427         vector<string> const path = getEnvPath("PATH");
428         vector<string>::const_iterator it = path.begin();
429         vector<string>::const_iterator const end = path.end();
430         for (; it != end; ++it) {
431                 // This will do nothing if *it is already absolute.
432                 string const exe_dir = makeAbsPath(*it).absFilename();
433
434                 FileName const exe_path(addName(exe_dir, exe_name));
435                 if (exe_path.exists())
436                         return exe_path;
437         }
438
439         // Didn't find anything.
440         return FileName();
441 }
442
443
444 // Extracts the absolute path to the binary name received as argv[0].
445 FileName const abs_path_from_binary_name(string const & exe)
446 {
447         FileName const abs_binary = get_binary_path(exe);
448         if (abs_binary.empty()) {
449                 // FIXME UNICODE
450                 throw ExceptionMessage(ErrorException,
451                         _("LyX binary not found"),
452                         bformat(_("Unable to determine the path to the LyX binary from the command line %1$s"),
453                                 from_utf8(exe)));
454         }
455         return abs_binary;
456 }
457
458
459 // A plethora of directories is searched to ascertain the system
460 // lyxdir which is defined as the first directory to contain
461 // "chkconfig.ltx".
462 FileName const
463 get_system_support_dir(FileName const & abs_binary,
464                   string const & command_line_system_support_dir)
465 {
466         string const chkconfig_ltx = "chkconfig.ltx";
467
468         // searched_dirs is used for diagnostic purposes only in the case
469         // that "chkconfig.ltx" is not found.
470         list<FileName> searched_dirs;
471
472         // 1. Use the -sysdir command line parameter.
473         FileName path = abs_path_from_command_line(command_line_system_support_dir);
474         if (!path.empty()) {
475                 searched_dirs.push_back(path);
476                 if (check_command_line_dir(path.absFilename(), chkconfig_ltx, "-sysdir"))
477                         return path;
478         }
479
480         // 2. Use the "LYX_DIR_15x" environment variable.
481         path = extract_env_var_dir("LYX_DIR_15x");
482         if (!path.empty()) {
483                 searched_dirs.push_back(path);
484                 if (check_env_var_dir(path, chkconfig_ltx, "LYX_DIR_15x"))
485                         return path;
486         }
487
488         // 3. Search relative to the lyx binary.
489         // We're looking for "chkconfig.ltx" in a directory
490         //   OnlyPath(abs_binary) / <relative dir> / PACKAGE /
491         // PACKAGE is hardcoded in config.h. Eg "lyx" or "lyx-1.3.6cvs".
492         // <relative dir> is OS-dependent; on Unix, it will be "../share/".
493         string const relative_lyxdir = relative_system_support_dir();
494
495         // One subtlety to be aware of. The name of the lyx binary may be
496         // a symbolic link. If that is the case, then we follow the links too.
497         FileName binary = abs_binary;
498         while (true) {
499                 // Try and find "chkconfig.ltx".
500                 string const binary_dir = onlyPath(binary.absFilename());
501
502                 FileName const lyxdir(addPath(binary_dir, relative_lyxdir));
503                 searched_dirs.push_back(lyxdir);
504
505                 if (!fileSearch(lyxdir.absFilename(), chkconfig_ltx).empty()) {
506                         // Success! "chkconfig.ltx" has been found.
507                         return lyxdir;
508                 }
509
510                 // Check whether binary is a symbolic link.
511                 // If so, resolve it and repeat the exercise.
512                 if (!binary.isSymLink())
513                         break;
514
515                 FileName link;
516                 if (readLink(binary, link)) {
517                         binary = link;
518                 } else {
519                         // Unable to resolve the link.
520                         break;
521                 }
522         }
523
524         // 4. Repeat the exercise on the directory itself.
525         FileName binary_dir(onlyPath(abs_binary.absFilename()));
526         while (true) {
527                 // This time test whether the directory is a symbolic link
528                 // *before* looking for "chkconfig.ltx".
529                 // (We've looked relative to the original already.)
530                 if (!binary.isSymLink())
531                         break;
532
533                 FileName link;
534                 if (readLink(binary_dir, link)) {
535                         binary_dir = link;
536                 } else {
537                         // Unable to resolve the link.
538                         break;
539                 }
540
541                 // Try and find "chkconfig.ltx".
542                 FileName const lyxdir(addPath(binary_dir.absFilename(),
543                         relative_lyxdir));
544                 searched_dirs.push_back(lyxdir);
545
546                 if (!fileSearch(lyxdir.absFilename(), chkconfig_ltx).empty()) {
547                         // Success! "chkconfig.ltx" has been found.
548                         return lyxdir;
549                 }
550         }
551
552         // 5. In desparation, try the hard-coded system support dir.
553         path = hardcoded_system_support_dir();
554         if (!fileSearch(path.absFilename(), chkconfig_ltx).empty())
555                 return path;
556
557         // Everything has failed :-(
558         // So inform the user and exit.
559         string searched_dirs_str;
560         typedef list<FileName>::const_iterator iterator;
561         iterator const begin = searched_dirs.begin();
562         iterator const end = searched_dirs.end();
563         for (iterator it = begin; it != end; ++it) {
564                 if (it != begin)
565                         searched_dirs_str += "\n\t";
566                 searched_dirs_str += it->absFilename();
567         }
568
569         // FIXME UNICODE
570         throw ExceptionMessage(ErrorException, _("No system directory"),
571                 bformat(_("Unable to determine the system directory "
572                                          "having searched\n"
573                                          "\t%1$s\n"
574                                          "Use the '-sysdir' command line parameter or "
575                                          "set the environment variable LYX_DIR_15x to "
576                                          "the LyX system directory containing the file "
577                                          "`chkconfig.ltx'."),
578                           from_utf8(searched_dirs_str)));
579
580         // Keep the compiler happy.
581         return FileName();
582 }
583
584
585 // Returns the absolute path to the user lyxdir, together with a flag
586 // indicating whether this directory was specified explicitly (as -userdir
587 // or through an environment variable) or whether it was deduced.
588 bool userSupportDir(FileName const & default_user_support_dir,
589         string const & command_line_user_support_dir, FileName & result)
590 {
591         // 1. Use the -userdir command line parameter.
592         result = abs_path_from_command_line(command_line_user_support_dir);
593         if (!result.empty())
594                 return true;
595
596         // 2. Use the LYX_USERDIR_15x environment variable.
597         result = extract_env_var_dir("LYX_USERDIR_15x");
598         if (!result.empty())
599                 return true;
600
601         // 3. Use the OS-dependent default_user_support_dir
602         result = default_user_support_dir;
603         return false;
604 }
605
606
607 // $HOME/.lyx on POSIX but on Win32 it will be something like
608 // "C:/Documents and Settings/USERNAME/Application Data/LyX"
609 FileName const get_default_user_support_dir(FileName const & home_dir)
610 {
611 #if defined (USE_WINDOWS_PACKAGING)
612         (void)home_dir; // Silence warning about unused variable.
613
614         os::GetFolderPath win32_folder_path;
615         return FileName(addPath(win32_folder_path(os::GetFolderPath::APPDATA), PACKAGE));
616
617 #elif defined (USE_MACOSX_PACKAGING)
618         (void)home_dir; // Silence warning about unused variable.
619
620         FSRef fsref;
621         OSErr const error_code =
622                 FSFindFolder(kUserDomain, kApplicationSupportFolderType,
623                              kDontCreateFolder, &fsref);
624         if (error_code != 0)
625                 return FileName();
626
627         // FSRefMakePath returns the result in utf8
628         char store[PATH_MAX + 1];
629         OSStatus const status_code =
630                 FSRefMakePath(&fsref,
631                               reinterpret_cast<UInt8*>(store), PATH_MAX);
632         if (status_code != 0)
633                 return FileName();
634
635         return FileName(addPath(reinterpret_cast<char const *>(store), PACKAGE));
636
637 #else // USE_POSIX_PACKAGING
638         return FileName(addPath(home_dir.absFilename(), string(".") + PACKAGE));
639 #endif
640 }
641
642
643 // Check that directory @c dir contains @c file.
644 // Else emit an error message about an invalid @c command_line_switch.
645 bool check_command_line_dir(string const & dir,
646                             string const & file,
647                             string const & command_line_switch)
648 {
649         FileName const abs_path = fileSearch(dir, file);
650         if (abs_path.empty()) {
651                 // FIXME UNICODE
652                 throw ExceptionMessage(ErrorException, _("File not found"), bformat(
653                         _("Invalid %1$s switch.\nDirectory %2$s does not contain %3$s."),
654                         from_utf8(command_line_switch), from_utf8(dir),
655                         from_utf8(file)));
656         }
657
658         return !abs_path.empty();
659 }
660
661
662 // The environment variable @c env_var expands to a (single) file path.
663 FileName const extract_env_var_dir(string const & env_var)
664 {
665         string const dir = fix_dir_name(getEnv(env_var));
666         return dir.empty() ? FileName() : makeAbsPath(dir);
667 }
668
669
670 // Check that directory @c dir contains @c file.
671 // Else emit a warning about an invalid @c env_var.
672 bool check_env_var_dir(FileName const & dir,
673                        string const & file,
674                        string const & env_var)
675 {
676         FileName const abs_path = fileSearch(dir.absFilename(), file);
677         if (abs_path.empty()) {
678                 // FIXME UNICODE
679                 throw ExceptionMessage(WarningException, _("File not found"), bformat(
680                         _("Invalid %1$s environment variable.\n"
681                                 "Directory %2$s does not contain %3$s."),
682                         from_utf8(env_var), from_utf8(dir.absFilename()),
683                         from_utf8(file)));
684         }
685
686         return !abs_path.empty();
687 }
688
689
690 // Check that directory @c dir is indeed a directory.
691 // Else emit a warning about an invalid @c env_var.
692 bool check_env_var_dir(FileName const & dir,
693                        string const & env_var)
694 {
695         bool const success = dir.exists() && dir.isDirectory();
696
697         if (!success) {
698                 // Put this string on a single line so that the gettext
699                 // search mechanism in po/Makefile.in.in will register
700                 // Package.cpp.in as a file containing strings that need
701                 // translation.
702                 // FIXME UNICODE
703                 docstring const fmt =
704                         _("Invalid %1$s environment variable.\n%2$s is not a directory.");
705
706                 throw ExceptionMessage(WarningException, _("Directory not found"), bformat(
707                         fmt, from_utf8(env_var), from_utf8(dir.absFilename())));
708         }
709
710         return success;
711 }
712
713
714 // The locale directory relative to the LyX system directory.
715 string const relative_locale_dir()
716 {
717 #if defined (USE_WINDOWS_PACKAGING) || defined (USE_MACOSX_PACKAGING)
718         return "locale/";
719 #else
720         return "../locale/";
721 #endif
722 }
723
724
725 // The system lyxdir is relative to the directory containing the LyX binary.
726 string const relative_system_support_dir()
727 {
728         string result;
729
730 #if defined (USE_WINDOWS_PACKAGING) || defined (USE_MACOSX_PACKAGING)
731         result = "../Resources/";
732 #else // Posix-like.
733         result = addPath("../share/", PACKAGE);
734 #endif
735
736         return result;
737 }
738
739 } // namespace anon
740
741 } // namespace support
742 } // namespace lyx