#include <config.h>
+#include "LyXRC.h"
+
#include "support/os.h"
#include "support/docstring.h"
+#include "support/environment.h"
#include "support/FileName.h"
+#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/lassert.h"
}
+string latex_path_list(string const & p)
+{
+ return p;
+}
+
+
bool is_valid_strftime(string const & p)
{
string::size_type pos = p.find_first_of('%');
}
-bool is_terminal(io_channel channel)
+shell_type shell()
{
- return isatty(channel);
+ return UNIX;
}
-shell_type shell()
+int timeout_min()
{
- return UNIX;
+ return 3;
}
-char path_separator()
+char path_separator(path_type)
{
return ':';
}
}
-bool autoOpenFile(string const & filename, auto_open_mode const mode)
+bool autoOpenFile(string const & filename, auto_open_mode const mode,
+ string const & path)
{
#ifdef __APPLE__
// Reference: http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/
if (status == kLSApplicationNotFoundErr)
return false;
+ string const texinputs = os::latex_path_list(
+ replaceCurdirPath(path, lyxrc.texinputs_prefix));
+ string const oldval = getEnv("TEXINPUTS");
+ string const newval = ".:" + texinputs + ":" + oldval;
+ if (!path.empty() && !lyxrc.texinputs_prefix.empty())
+ setEnv("TEXINPUTS", newval);
+
LSLaunchFSRefSpec inLaunchSpec;
inLaunchSpec.appRef = &outAppRef;
inLaunchSpec.numDocs = 1;
inLaunchSpec.asyncRefCon = NULL;
status = LSOpenFromRefSpec(&inLaunchSpec, NULL);
+ if (!path.empty() && !lyxrc.texinputs_prefix.empty())
+ setEnv("TEXINPUTS", oldval);
+
return status != kLSApplicationNotFoundErr;
#else
// silence compiler warnings
(void)filename;
(void)mode;
+ (void)path;
// currently, no default viewer is tried for non-windows system
// support for KDE/Gnome/Macintosh may be added later
string real_path(string const & path)
{
+#ifdef HAVE_DEF_PATH_MAX
char rpath[PATH_MAX + 1];
char * result = realpath(path.c_str(), rpath);
return FileName::fromFilesystemEncoding(result ? rpath : path).absFileName();
+#else
+ char * result = realpath(path.c_str(), NULL);
+ string ret = FileName::fromFilesystemEncoding(result ? result : path).absFileName();
+ free(result);
+ return ret;
+#endif
}
} // namespace os