Luis Rivera wrote:
Hello,
I am happy to report that LyX137cvs2 actually runs on Win95 (an old
486, 16Mb memory!)... however, with a few caveats,
0/ installer breaks on running configure, as it did before on Win98...
1/ the already reported problems with the fonts in menus, etc...
2/ it only works when the environment variable lyx_dir_13x or the
-sysdir option
are set to the SHORT path of the LyX executable.
So apparently the wrapper to convert long to short paths on Win95
is still broken...
As promised, Luis, here is a standalone version of the paths thing for you
to play with. It was just missing a few #includes...
Angus
// From os_win32.h (BRANCH_1_3_X)
/* The GetLongPathNameA function declaration in
* <winbase.h> is protected by the WINVER macro which is
* defined to a default value in <windef.h> under MinGW and Cygwin.
*
* SHGFP_TYPE_CURRENT is defined in <shlobj.h> for __W32API_VERSION >= 3.2
* where it is protected by _WIN32_IE, also defined to a default value
* in <windef.h> under MinGW and Cygwin.
* It is missing in earlier versions of the MinGW w32api headers.
*
* We need to #include <windows.h> now to make available the
* DWORD, HMODULE et al. typedefs, so first define WINVER, _WIN32_IE.
*
* Note: __CYGWIN__ can be defined here if building in _WIN32 mode.
*/
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
using std::cerr;
using std::cout;
using std::endl;
using std::string;
using std::vector;
#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__CYGWIN32__)
# if defined(WINVER) && WINVER < 0x0500
# error WINVER must be >= 0x0500
# endif
# define WINVER 0x0500
# define _WIN32_IE 0x0500
#endif
#include <windows.h>
// From os_win32.C (BRANCH_1_3_X)
/* The GetLongPathName macro may be defined on the compiling machine,
* but we must use a bit of trickery if the resulting executable is
* to run on a Win95 machine.
* Fortunately, Microsoft provide the trickery. All we need is the
* NewAPIs.h header file, available for download from Microsoft as
* part of the Platform SDK.
*/
#if defined (HAVE_NEWAPIS_H)
# define WANT_GETLONGPATHNAME_WRAPPER 1
# define COMPILE_NEWAPIS_STUBS
# include <NewAPIs.h>
# undef COMPILE_NEWAPIS_STUBS
# undef WANT_GETLONGPATHNAME_WRAPPER
#endif
namespace {
string const get_long_path(string const & short_path)
{
std::vector<char> long_path(MAX_PATH);
DWORD result = GetLongPathName(short_path.c_str(),
&long_path[0], long_path.size());
if (result > long_path.size()) {
long_path.resize(result);
result = GetLongPathName(short_path.c_str(),
&long_path[0], long_path.size());
assert(result <= long_path.size());
}
return (result == 0) ? short_path : &long_path[0];
}
} // namespace anon
// From the code you attached.
int main(int argc, char * argv[])
{
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " some_path\n";
return -1;
}
// Windows 95 has GetShortPathName even if it doesn't have
// GetLongPathName!
char short_path[MAX_PATH];
DWORD const result = GetShortPathName(argv[1], short_path, MAX_PATH);
if (result == 0 || result > MAX_PATH) {
std::cerr << "Unable to ascertain ShortPath version of " <<
argv[1] << '\n';
return -1;
}
string const long_path = get_long_path(short_path);
std::cout << "Short path name is " << short_path << '\n'
<< "Long path name is " << long_path << std::endl;
return 0;
}