Angus Leeming <[EMAIL PROTECTED]> writes:

| There are no symbolic links on Windows. These patches add HAVE_LSTAT and
| HAVE_READLINK to config.h and use 'em.
>

> OK to apply? To 13x too, Jean-Marc?

I am not quite fond of the code...

| Index: src/support/FileInfo.C
| ===================================================================
| RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/FileInfo.C,v
| retrieving revision 1.25
| diff -u -p -r1.25 FileInfo.C
| --- src/support/FileInfo.C    15 Dec 2004 21:40:11 -0000      1.25
| +++ src/support/FileInfo.C    3 Jan 2005 20:49:03 -0000
| @@ -16,6 +16,8 @@
|  
|  #include <cerrno>
|  
| +#include <sys/types.h>
| +#include <sys/stat.h>
|  
|  using std::string;
|  
| @@ -180,10 +182,20 @@ void FileInfo::init()
|  
|  void FileInfo::dostat(bool link)
|  {
| +     string name(fname_);
| +#ifdef _WIN32
| +     // Win32 stat() doesn't dig trailing slashes    
| +     if (name.at(name.size()-1) == '/') name.erase(name.size() -1);
| +#endif

at? We don't use excedptions so you will get an abort instead...

And why not just remove trailing slash for other systems as well?
Why not make sure that fname_ is stored without trailing slash.

| +#ifdef HAVE_LSTAT
|       if (link)
| -             status_ = ::lstat(fname_.c_str(), &buf_);
| +             status_ = ::lstat(name.c_str(), &buf_);
|       else
| -             status_ = ::stat(fname_.c_str(), &buf_);
| +             status_ = ::stat(name.c_str(), &buf_);
| +#else
| +     status_ = ::stat(name.c_str(), &buf_);
| +#endif

We should perhaps even think about having lyx::support::[l]stat
wrappers. (Actually I'd like to get rid of FileInfo.)

-- 
        Lgb

Reply via email to