mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-18 21:45:24 +00:00
Query the cygdrive prefix only if the cygwin mount command is available.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@33026 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
73804b56d5
commit
772a032cd0
@ -154,40 +154,47 @@ void init(int /* argc */, char * argv[])
|
|||||||
* lyx is invoked as a parameter of hidecmd.exe.
|
* lyx is invoked as a parameter of hidecmd.exe.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// If Cygwin is detected, query the cygdrive prefix
|
// If Cygwin is detected, query the cygdrive prefix.
|
||||||
HKEY regKey;
|
// The cygdrive prefix is needed for translating windows style paths
|
||||||
LONG retVal;
|
// to posix style paths in LaTeX files when the Cygwin teTeX is used.
|
||||||
|
int i;
|
||||||
// Check for Cygwin 1.7 or later
|
HKEY hkey;
|
||||||
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
char buf[MAX_PATH];
|
||||||
"Software\\Cygwin\\setup",
|
DWORD bufsize = sizeof(buf);
|
||||||
0, KEY_QUERY_VALUE, ®Key);
|
LONG retval = ERROR_FILE_NOT_FOUND;
|
||||||
if (retVal != ERROR_SUCCESS)
|
HKEY const mainkey[2] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER };
|
||||||
retVal = RegOpenKeyEx(HKEY_CURRENT_USER,
|
char const * const subkey[2] = {
|
||||||
"Software\\Cygwin\\setup",
|
"Software\\Cygwin\\setup", // Cygwin 1.7
|
||||||
0, KEY_QUERY_VALUE, ®Key);
|
"Software\\Cygnus Solutions\\Cygwin\\mounts v2\\/" // Prev. ver.
|
||||||
|
};
|
||||||
// Check for older Cygwin versions
|
char const * const valuename[2] = {
|
||||||
if (retVal != ERROR_SUCCESS)
|
"rootdir", // Cygwin 1.7 or later
|
||||||
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
"native" // Previous versions
|
||||||
"Software\\Cygnus Solutions\\Cygwin\\mounts v2",
|
};
|
||||||
0, KEY_QUERY_VALUE, ®Key);
|
// Check for newer Cygwin versions first, then older ones
|
||||||
if (retVal != ERROR_SUCCESS)
|
for (i = 0; i < 2 && retval != ERROR_SUCCESS; ++i) {
|
||||||
retVal = RegOpenKeyEx(HKEY_CURRENT_USER,
|
for (int k = 0; k < 2 && retval != ERROR_SUCCESS; ++k)
|
||||||
"Software\\Cygnus Solutions\\Cygwin\\mounts v2",
|
retval = RegOpenKey(mainkey[k], subkey[i], &hkey);
|
||||||
0, KEY_QUERY_VALUE, ®Key);
|
}
|
||||||
|
if (retval == ERROR_SUCCESS) {
|
||||||
if (retVal == ERROR_SUCCESS) {
|
// Query the Cygwin root directory
|
||||||
RegCloseKey(regKey);
|
retval = RegQueryValueEx(hkey, valuename[i - 1],
|
||||||
cmd_ret const p = runCommand("mount --show-cygdrive-prefix");
|
NULL, NULL, (LPBYTE) buf, &bufsize);
|
||||||
// The output of the mount command is as follows:
|
RegCloseKey(hkey);
|
||||||
// Prefix Type Flags
|
string const mount = string(buf) + "\\bin\\mount.exe";
|
||||||
// /cygdrive system binmode
|
if (retval == ERROR_SUCCESS && FileName(mount).exists()) {
|
||||||
// So, we use the inner split to pass the second line to the
|
cmd_ret const p =
|
||||||
// outer split which sets cygdrive with its contents until
|
runCommand(mount + " --show-cygdrive-prefix");
|
||||||
// the first blank, discarding the unneeded return value.
|
// The output of the mount command is as follows:
|
||||||
if (p.first != -1 && prefixIs(p.second, "Prefix"))
|
// Prefix Type Flags
|
||||||
split(split(p.second, '\n'), cygdrive, ' ');
|
// /cygdrive system binmode
|
||||||
|
// So, we use the inner split to pass the second line
|
||||||
|
// to the outer split which sets cygdrive with its
|
||||||
|
// contents until the first blank, discarding the
|
||||||
|
// unneeded return value.
|
||||||
|
if (p.first != -1 && prefixIs(p.second, "Prefix"))
|
||||||
|
split(split(p.second, '\n'), cygdrive, ' ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Catch shutdown events.
|
// Catch shutdown events.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user