Lars Gullik Bjønnes wrote:
> | Try the attached patch. Happier with it?
> Yes, a lot.
>
> | +string const stored_path(string const & path)
> except the name perhaps.
> and why not just use trim?
> rtrim(path, "/")
Good again. Thanks, Lars.
--
Angus
Index: config/configure.ac
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/config/Attic/configure.ac,v
retrieving revision 1.24.2.25
diff -u -p -r1.24.2.25 configure.ac
--- config/configure.ac 16 Dec 2004 01:03:37 -0000 1.24.2.25
+++ config/configure.ac 4 Jan 2005 08:57:45 -0000
@@ -256,8 +256,10 @@ dnl work correctly because of some confl
dnl We aim to remove this eventually, since we should test as much as
dnl possible with the compiler which will use the functions (JMarc)
AC_LANG_PUSH(C)
-AC_CHECK_FUNCS(memmove memset strchr putenv setenv mkfifo mkstemp mktemp)
+AC_CHECK_FUNCS(memmove memset strchr putenv setenv mkfifo mkstemp mktemp \
+ lstat readlink)
AC_LANG_POP(C)
+
dnl Until this is fixed in autoconf we provide our own version
AC_FUNC_SELECT_ARGTYPES
Index: config/configure.in
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/config/Attic/configure.in,v
retrieving revision 1.17.2.23
diff -u -p -r1.17.2.23 configure.in
--- config/configure.in 6 Oct 2004 15:03:39 -0000 1.17.2.23
+++ config/configure.in 4 Jan 2005 08:57:46 -0000
@@ -259,7 +259,8 @@ dnl work correctly because of some confl
dnl We aim to remove this eventually, since we should test as much as
dnl possible with the compiler which will use the functions (JMarc)
AC_LANG_C
-AC_CHECK_FUNCS(memmove memset strchr putenv setenv mkfifo mkstemp mktemp)
+AC_CHECK_FUNCS(memmove memset strchr putenv setenv mkfifo mkstemp mktemp \
+ lstat readlink)
AC_LANG_CPLUSPLUS
dnl Until this is fixed in autoconf we provide our own version
Index: src/support/FileInfo.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/FileInfo.C,v
retrieving revision 1.18.2.2
diff -u -p -r1.18.2.2 FileInfo.C
--- src/support/FileInfo.C 15 Dec 2004 21:40:03 -0000 1.18.2.2
+++ src/support/FileInfo.C 4 Jan 2005 08:57:46 -0000
@@ -10,8 +10,10 @@
#include <config.h>
-//#include <sys/types.h>
-//#include <sys/stat.h>
+#include <lstrings.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
#include <cerrno>
#include "FileInfo.h"
@@ -138,7 +140,6 @@ char typeLetter(mode_t i)
return '?';
}
-
} // namespace anon
@@ -149,7 +150,9 @@ FileInfo::FileInfo()
FileInfo::FileInfo(string const & path, bool link)
- : fname_(path)
+ // Win32 stat() doesn't dig trailing slashes.
+ // Posix stat() doesn't care, but we'll remove it anyway.
+ : fname_(rtrim(path, "/"))
{
init();
dostat(link);
@@ -174,10 +177,15 @@ void FileInfo::init()
void FileInfo::dostat(bool link)
{
+#ifdef HAVE_LSTAT
if (link)
status_ = ::lstat(fname_.c_str(), &buf_);
else
status_ = ::stat(fname_.c_str(), &buf_);
+#else
+ status_ = ::stat(fname_.c_str(), &buf_);
+#endif
+
if (status_)
err_ = errno;
}
@@ -185,7 +193,9 @@ void FileInfo::dostat(bool link)
FileInfo & FileInfo::newFile(string const & path, bool link)
{
- fname_ = path;
+ // Win32 stat() doesn't dig trailing slashes.
+ // Posix stat() doesn't care, but we'll remove it anyway.
+ fname_ = rtrim(path, "/");
status_ = 0;
err_ = NoErr;
dostat(link);
@@ -308,7 +318,11 @@ bool FileInfo::isOK() const
bool FileInfo::isLink() const
{
lyx::Assert(isOK());
+#ifdef S_ISLNK
return S_ISLNK(buf_.st_mode);
+#else
+ return false;
+#endif
}
Index: src/support/filetools.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
retrieving revision 1.146.2.8
diff -u -p -r1.146.2.8 filetools.C
--- src/support/filetools.C 20 Dec 2004 16:59:01 -0000 1.146.2.8
+++ src/support/filetools.C 4 Jan 2005 08:57:47 -0000
@@ -1247,6 +1247,7 @@ string const MakeDisplayPath(string cons
bool LyXReadLink(string const & file, string & link, bool resolve)
{
+#ifdef HAVE_READLINK
char linkbuffer[512];
// Should be PATH_MAX but that needs autconf support
int const nRead = ::readlink(file.c_str(),
@@ -1259,6 +1260,9 @@ bool LyXReadLink(string const & file, st
else
link = linkbuffer;
return true;
+#else
+ return false;
+#endif
}