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?

-- 
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	3 Jan 2005 20:47:57 -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	3 Jan 2005 20:47:57 -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	3 Jan 2005 20:47:57 -0000
@@ -10,8 +10,8 @@
 
 #include <config.h>
 
-//#include <sys/types.h>
-//#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #include <cerrno>
 #include "FileInfo.h"
@@ -174,10 +174,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
+#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
+
 	if (status_)
 		err_ = errno;
 }
@@ -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	3 Jan 2005 20:47:59 -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
 }
 
 
Index: configure.ac
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/configure.ac,v
retrieving revision 1.33
diff -u -p -r1.33 configure.ac
--- configure.ac	28 Dec 2004 13:48:48 -0000	1.33
+++ configure.ac	3 Jan 2005 20:49:02 -0000
@@ -293,7 +293,7 @@ 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(mkfifo mkstemp mktemp)
+AC_CHECK_FUNCS(mkfifo mkstemp mktemp lstat readlink)
 AC_LANG_POP(C)
 
 AC_FUNC_SELECT_ARGTYPES
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
+#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
+
 	if (status_)
 		err_ = errno;
 }
@@ -314,7 +326,11 @@ bool FileInfo::isOK() const
 bool FileInfo::isLink() const
 {
 	BOOST_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.193
diff -u -p -r1.193 filetools.C
--- src/support/filetools.C	20 Dec 2004 16:59:33 -0000	1.193
+++ src/support/filetools.C	3 Jan 2005 20:49:04 -0000
@@ -1145,6 +1145,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(),
@@ -1157,6 +1158,9 @@ bool LyXReadLink(string const & file, st
 	else
 		link = linkbuffer;
 	return true;
+#else
+	return false;
+#endif
 }
 
 

Reply via email to