On Tuesday 27 September 2005 21:19, [EMAIL PROTECTED] wrote:
> Dear Angus,
>
> It seems that it works,

excellent!

I have two new versions of the package for you to try out. See below for 
explanations.

This one will still fail but will tell us why it is failing:
http://wiki.lyx.org/uploads/LaTeX/tex2lyx/tex2lyx_win32_27sep05_throwing.zip

This one will work. (I hope.)
http://wiki.lyx.org/uploads/LaTeX/tex2lyx/tex2lyx_win32_27sep05_testing.zip

> but complained: 
> Exception caught:
> boost::filesystem::is_directory:
> "J:\MinSYS\home\Angus\lyx\devel\build-tex2lyx\L
> yX-1.4\Resources\LyX\chkconfig.ltx": Access is denied.
> Assertion triggered in void boost::throw_exception(const std::exception&)
> by fai ling check "false" in file ../../../src/tex2lyx/boost.C:28

In some ways this is great. It means that you're falling through to test for 
the existence of a hard-coded path (on my machine) in your attempts to 
discover whether you are running tex2lyx from its build tree or from the 
installed tree (installed tree for you).

What's less good is that the test which should protect us from the exception 
being thrown isn't working:

    if (fs::exists(path) && fs::is_directory(path))

we shouldn't call is_directory() if the file doesn't exist. The code in 
question is:

    BOOST_FILESYSTEM_DECL bool exists( const path & ph )
    {
      if(::GetFileAttributesA( ph.string().c_str() ) == 0xFFFFFFFF)
      {
         UINT err = ::GetLastError();
         if((err == ERROR_FILE_NOT_FOUND) || 
            (err == ERROR_INVALID_PARAMETER) || 
            (err == ERROR_PATH_NOT_FOUND) ||
            (err == ERROR_INVALID_NAME))
            // GetFileAttributes failed because the path does not exist
            return false;
         // for any other error we assume the file does exist and fall
         // through, this may not be the best policy though...  (JM 20040330)
         return true;
      }
      return true;
    }

Clearly, the test is failing but with an untested for value. In our case this 
certainly isn't "the best policy though".

I think we should add
         boost::throw_exception( fs::filesystem_error(
           "boost::filesystem::exists",
           ph, fs::detail::system_error_code() ) );
in place of the "return true". The thing will still fail, but we'll find out 
why. 

I suspect that it'll end up as ERROR_INVALID_DRIVE... Interstingly, here, on a 
WinXP machine. All is fine. Ie, I get an "expected" error if I look for a 
file on a non-existent drive.

Anyway, this is the ..._throwing.zip package. Would be great if you'd try it 
out.

The other ..._testing.zip package returns false unconditionally if we get an 
error in the exists() routine. So, it should "just work", but the "fix" 
probably isn't acceptable to the code's author, so we'll need your diagnosis 
too.

Angus

Reply via email to