mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-19 05:53:35 +00:00
* Replace all use of 'slashify_path' with 'internal_path'.
* Specialise 'internal_path' and 'external_path' for Windows and Cygwin. * Enable LyX to find its system_lyxdir on Windows. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_3_X@9400 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ee8028b9e4
commit
ea768f414b
@ -1,4 +1,13 @@
|
|||||||
2004-12-14 Angus Leeming <leeming@lyx.org>
|
2004-12-19 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* lyx_main.C (init): on a Windows build, remove the ".exe"
|
||||||
|
extension from the name of the LyX binary when trying to
|
||||||
|
ascertain the name of the LyX system directory.
|
||||||
|
(Usually, <path to binary>/../share/<name of binary>/).
|
||||||
|
|
||||||
|
* buffer.C (save): s/slashify_path/internal_path/.
|
||||||
|
|
||||||
|
2004-12-14 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* LaTeX.C: (operator()): use os::nulldev() rather than "/dev/null".
|
* LaTeX.C: (operator()): use os::nulldev() rather than "/dev/null".
|
||||||
|
|
||||||
|
@ -1286,7 +1286,7 @@ bool Buffer::save() const
|
|||||||
s = fileName() + '~';
|
s = fileName() + '~';
|
||||||
if (!lyxrc.backupdir_path.empty())
|
if (!lyxrc.backupdir_path.empty())
|
||||||
s = AddName(lyxrc.backupdir_path,
|
s = AddName(lyxrc.backupdir_path,
|
||||||
subst(os::slashify_path(s),'/','!'));
|
subst(os::internal_path(s),'/','!'));
|
||||||
|
|
||||||
// Rename is the wrong way of making a backup,
|
// Rename is the wrong way of making a backup,
|
||||||
// this is the correct way.
|
// this is the correct way.
|
||||||
|
@ -288,8 +288,18 @@ void LyX::init(bool gui)
|
|||||||
bool followlink;
|
bool followlink;
|
||||||
do {
|
do {
|
||||||
// Path of binary/../share/name of binary/
|
// Path of binary/../share/name of binary/
|
||||||
searchpath += NormalizePath(AddPath(binpath, "../share/") +
|
string const exe_name = OnlyFilename(binname);
|
||||||
OnlyFilename(binname)) + ';';
|
#ifdef _WIN32
|
||||||
|
string const lyx_system_dir_name =
|
||||||
|
suffixIs(exe_name, ".exe") ?
|
||||||
|
ChangeExtension(exe_name, "") :
|
||||||
|
exe_name;
|
||||||
|
#else
|
||||||
|
string const lyx_system_dir_name = exe_name;
|
||||||
|
#endif
|
||||||
|
string const shared_dir_name =
|
||||||
|
NormalizePath(AddPath(binpath, "../share/"));
|
||||||
|
searchpath += shared_dir_name + lyx_system_dir_name + ';';
|
||||||
|
|
||||||
// Follow Symlinks
|
// Follow Symlinks
|
||||||
FileInfo file(fullbinpath, true);
|
FileInfo file(fullbinpath, true);
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
2004-12-19 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* os.h, os_os2.C, os_unix.C, os_win32.C (slashify_path): remove.
|
||||||
|
|
||||||
|
* os_win32.C (init): ensure that the name of the lyx executable is
|
||||||
|
stored internally with a unix-style path.
|
||||||
|
|
||||||
|
* os_win32.C (internal_path, external_path): differentiate between
|
||||||
|
cygwin and windows builds.
|
||||||
|
|
||||||
|
* filetools.C (FileOpenSearch, GetEnvPath, createDirectory,
|
||||||
|
MakeAbsPath, AddName, MakeRelPath, ChangeExtension):
|
||||||
|
s/slashify_path/internal_path/.
|
||||||
|
|
||||||
2004-12-16 Angus Leeming <leeming@lyx.org>
|
2004-12-16 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* mkdir.C: move the HAVE_MKDIR conditional code out of config.h
|
* mkdir.C: move the HAVE_MKDIR conditional code out of config.h
|
||||||
|
@ -177,7 +177,7 @@ string const FileOpenSearch(string const & path, string const & name,
|
|||||||
string tmppath = split(path, path_element, ';');
|
string tmppath = split(path, path_element, ';');
|
||||||
|
|
||||||
while (notfound && !path_element.empty()) {
|
while (notfound && !path_element.empty()) {
|
||||||
path_element = os::slashify_path(path_element);
|
path_element = os::internal_path(path_element);
|
||||||
if (!suffixIs(path_element, '/'))
|
if (!suffixIs(path_element, '/'))
|
||||||
path_element+= '/';
|
path_element+= '/';
|
||||||
path_element = subst(path_element, "$$LyX", system_lyxdir);
|
path_element = subst(path_element, "$$LyX", system_lyxdir);
|
||||||
@ -369,7 +369,7 @@ string const GetEnvPath(string const & name)
|
|||||||
#ifndef __EMX__
|
#ifndef __EMX__
|
||||||
string const pathlist = subst(GetEnv(name), ':', ';');
|
string const pathlist = subst(GetEnv(name), ':', ';');
|
||||||
#else
|
#else
|
||||||
string const pathlist = os::slashify_path(GetEnv(name));
|
string const pathlist = os::internal_path(GetEnv(name));
|
||||||
#endif
|
#endif
|
||||||
return rtrim(pathlist, ";");
|
return rtrim(pathlist, ";");
|
||||||
}
|
}
|
||||||
@ -573,7 +573,7 @@ int DestroyLyXTmpDir(string const & tmpdir)
|
|||||||
// Creates directory. Returns true if succesfull
|
// Creates directory. Returns true if succesfull
|
||||||
bool createDirectory(string const & path, int permission)
|
bool createDirectory(string const & path, int permission)
|
||||||
{
|
{
|
||||||
string temp(rtrim(os::slashify_path(path), "/"));
|
string temp(rtrim(os::internal_path(path), "/"));
|
||||||
|
|
||||||
if (temp.empty()) {
|
if (temp.empty()) {
|
||||||
Alert::alert(_("Internal error!"),
|
Alert::alert(_("Internal error!"),
|
||||||
@ -613,7 +613,7 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath)
|
|||||||
return RelPath;
|
return RelPath;
|
||||||
|
|
||||||
// Copies given paths
|
// Copies given paths
|
||||||
string TempRel(os::slashify_path(RelPath));
|
string TempRel(os::internal_path(RelPath));
|
||||||
// Since TempRel is NOT absolute, we can safely replace "//" with "/"
|
// Since TempRel is NOT absolute, we can safely replace "//" with "/"
|
||||||
TempRel = subst(TempRel, "//", "/");
|
TempRel = subst(TempRel, "//", "/");
|
||||||
|
|
||||||
@ -664,7 +664,7 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns absolute path
|
// returns absolute path
|
||||||
return os::slashify_path(TempBase);
|
return os::internal_path(TempBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -679,7 +679,7 @@ string const AddName(string const & path, string const & fname)
|
|||||||
string buf;
|
string buf;
|
||||||
|
|
||||||
if (path != "." && path != "./" && !path.empty()) {
|
if (path != "." && path != "./" && !path.empty()) {
|
||||||
buf = os::slashify_path(path);
|
buf = os::internal_path(path);
|
||||||
if (!suffixIs(path, '/'))
|
if (!suffixIs(path, '/'))
|
||||||
buf += '/';
|
buf += '/';
|
||||||
}
|
}
|
||||||
@ -939,10 +939,10 @@ string const MakeRelPath(string const & abspath, string const & basepath)
|
|||||||
string const AddPath(string const & path, string const & path_2)
|
string const AddPath(string const & path, string const & path_2)
|
||||||
{
|
{
|
||||||
string buf;
|
string buf;
|
||||||
string const path2 = os::slashify_path(path_2);
|
string const path2 = os::internal_path(path_2);
|
||||||
|
|
||||||
if (!path.empty() && path != "." && path != "./") {
|
if (!path.empty() && path != "." && path != "./") {
|
||||||
buf = os::slashify_path(path);
|
buf = os::internal_path(path);
|
||||||
if (path[path.length() - 1] != '/')
|
if (path[path.length() - 1] != '/')
|
||||||
buf += '/';
|
buf += '/';
|
||||||
}
|
}
|
||||||
@ -976,7 +976,7 @@ string const ChangeExtension(string const & oldname, string const & extension)
|
|||||||
else
|
else
|
||||||
ext = extension;
|
ext = extension;
|
||||||
|
|
||||||
return os::slashify_path(oldname.substr(0, last_dot) + ext);
|
return os::internal_path(oldname.substr(0, last_dot) + ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,8 +43,6 @@ public:
|
|||||||
static string::size_type common_path(string const &p1,
|
static string::size_type common_path(string const &p1,
|
||||||
string const &p2);
|
string const &p2);
|
||||||
|
|
||||||
// no-op on UNIX, '\\'->'/' on OS/2 and Win32, ':'->'/' on MacOS, etc.
|
|
||||||
static string slashify_path(string p);
|
|
||||||
// Converts a unix style path to host OS style.
|
// Converts a unix style path to host OS style.
|
||||||
static string external_path(string const &p);
|
static string external_path(string const &p);
|
||||||
// Converts a host OS style path to unix style.
|
// Converts a host OS style path to unix style.
|
||||||
|
@ -34,7 +34,7 @@ void os::init(int argc, char * argv[])
|
|||||||
if (rc != NO_ERROR)
|
if (rc != NO_ERROR)
|
||||||
exit(rc);
|
exit(rc);
|
||||||
string p(tmp);
|
string p(tmp);
|
||||||
p = slashify_path(p);
|
p = internal_path(p);
|
||||||
binname_ = OnlyFilename(p);
|
binname_ = OnlyFilename(p);
|
||||||
binname_.erase(binname_.length()-4, string::npos);
|
binname_.erase(binname_.length()-4, string::npos);
|
||||||
binpath_ = OnlyPath(p);
|
binpath_ = OnlyPath(p);
|
||||||
@ -96,8 +96,8 @@ string::size_type os::common_path(string const &p1, string const &p2) {
|
|||||||
COUNTRYCODE cntry;
|
COUNTRYCODE cntry;
|
||||||
cntry.country = 0;
|
cntry.country = 0;
|
||||||
cntry.codepage = cp_;
|
cntry.codepage = cp_;
|
||||||
string temp1 = slashify_path(p1);
|
string temp1 = internal_path(p1);
|
||||||
string temp2 = slashify_path(p2);
|
string temp2 = internal_path(p2);
|
||||||
char * tmp1 = const_cast<char*> (temp1.c_str());
|
char * tmp1 = const_cast<char*> (temp1.c_str());
|
||||||
char * tmp2 = const_cast<char*> (temp2.c_str());
|
char * tmp2 = const_cast<char*> (temp2.c_str());
|
||||||
/* rc = */ DosMapCase(p1.length(), &cntry, tmp1);
|
/* rc = */ DosMapCase(p1.length(), &cntry, tmp1);
|
||||||
@ -120,7 +120,7 @@ string::size_type os::common_path(string const &p1, string const &p2) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
string os::slashify_path(string p) {
|
string os::internal_path(string const & p) {
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
static bool leadbyte[256] = {false};
|
static bool leadbyte[256] = {false};
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
@ -158,12 +158,7 @@ string os::slashify_path(string p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string os::external_path(string const &p) {
|
string os::external_path(string const & p) {
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
string os::internal_path(string const &p) {
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,15 +67,11 @@ string::size_type os::common_path(string const &p1, string const &p2) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
string os::slashify_path(string p) {
|
string os::internal_path(string const & p) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
string os::external_path(string const &p) {
|
string os::external_path(string const & p) {
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
string os::internal_path(string const &p) {
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,11 +34,12 @@ unsigned long os::cp_ = 0;
|
|||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
void os::init(int /* argc */, char * argv[]) {
|
void os::init(int /* argc */, char * argv[])
|
||||||
|
{
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
if (initialized) return;
|
if (initialized) return;
|
||||||
initialized = true;
|
initialized = true;
|
||||||
string tmp = argv[0];
|
string tmp = internal_path(argv[0]);
|
||||||
binname_ = OnlyFilename(tmp);
|
binname_ = OnlyFilename(tmp);
|
||||||
tmp = ExpandPath(tmp); // This expands ./ and ~/
|
tmp = ExpandPath(tmp); // This expands ./ and ~/
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ void os::init(int /* argc */, char * argv[]) {
|
|||||||
string binsearchpath = GetEnvPath("PATH");
|
string binsearchpath = GetEnvPath("PATH");
|
||||||
// This will make "src/lyx" work always :-)
|
// This will make "src/lyx" work always :-)
|
||||||
binsearchpath += ";.";
|
binsearchpath += ";.";
|
||||||
tmp = argv[0];
|
tmp = internal_path(argv[0]);
|
||||||
tmp = FileOpenSearch(binsearchpath, tmp);
|
tmp = FileOpenSearch(binsearchpath, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,17 +95,26 @@ string::size_type os::common_path(string const &p1, string const &p2) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
string os::slashify_path(string p) {
|
string os::external_path(string const & p)
|
||||||
return subst(p, '\\', '/');
|
{
|
||||||
}
|
string dos_path;
|
||||||
|
|
||||||
string os::external_path(string const & p) {
|
#ifdef __CYGWIN__
|
||||||
string dos_path=p;
|
// Translate from cygwin path syntax to dos path syntax
|
||||||
if (is_absolute_path(p)) {
|
if (is_absolute_path(p)) {
|
||||||
char dp[255];
|
char dp[MAX_PATH];
|
||||||
cygwin_conv_to_full_win32_path(p.c_str(), dp);
|
cygwin_conv_to_full_win32_path(p.c_str(), dp);
|
||||||
dos_path=subst(dp,'\\','/');
|
dos_path = !dp ? "" : dp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else return p;
|
||||||
|
#else // regular Win32
|
||||||
|
dos_path = p;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//No backslashes in LaTeX files
|
||||||
|
dos_path = subst(dos_path,'\\','/');
|
||||||
|
|
||||||
lyxerr[Debug::LATEX]
|
lyxerr[Debug::LATEX]
|
||||||
<< "<Win32 path correction> ["
|
<< "<Win32 path correction> ["
|
||||||
<< p << "]->>["
|
<< p << "]->>["
|
||||||
@ -117,10 +127,15 @@ string os::external_path(string const & p) {
|
|||||||
// files are mentioned in Win32/DOS syntax. Because LyX uses the dep file
|
// files are mentioned in Win32/DOS syntax. Because LyX uses the dep file
|
||||||
// entries to check if any file has been changed we must retranslate
|
// entries to check if any file has been changed we must retranslate
|
||||||
// the Win32/DOS pathnames into Cygwin pathnames.
|
// the Win32/DOS pathnames into Cygwin pathnames.
|
||||||
string os::internal_path(string const &p) {
|
string os::internal_path(string const & p)
|
||||||
char pp[256];
|
{
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
char pp[MAX_PATH];
|
||||||
cygwin_conv_to_posix_path(p.c_str(), pp);
|
cygwin_conv_to_posix_path(p.c_str(), pp);
|
||||||
string const posix_path = MakeLatexName(pp);
|
string const posix_path = MakeLatexName(pp);
|
||||||
|
#else
|
||||||
|
string const posix_path = subst(p,"\\","/");
|
||||||
|
#endif
|
||||||
lyxerr[Debug::DEPEND]
|
lyxerr[Debug::DEPEND]
|
||||||
<< "<Win32 path correction> ["
|
<< "<Win32 path correction> ["
|
||||||
<< p << "]->>["
|
<< p << "]->>["
|
||||||
|
Loading…
x
Reference in New Issue
Block a user