mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-13 17:20:55 +00:00
Test for OS support for symbolic links and protect support library code
appropriately. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_3_X@9420 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
987df09ed3
commit
783a311643
@ -1,3 +1,8 @@
|
||||
2005-01-04 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* configure.ac, configure.in (AC_CHECK_FUNCS): test for the
|
||||
existence of lstat and readlink.
|
||||
|
||||
2004-12-16 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* configure.ac: remove the HAVE_MKDIR conditional code to
|
||||
|
@ -256,9 +256,11 @@ dnl work correctly because of some conflict with stdlib.h with g++ 2.96
|
||||
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
|
||||
|
||||
|
@ -259,7 +259,8 @@ dnl work correctly because of some conflict with stdlib.h with g++ 2.96
|
||||
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
|
||||
|
@ -1,3 +1,13 @@
|
||||
2005-01-04 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* FileInfo.C (FileInfo, newFile): strip the trailing '/' from
|
||||
the stored file name as it breaks Window's version of stat().
|
||||
(isLink): protect the code with #ifdef S_ISLNK.
|
||||
(dostat): protect the code with #ifdef HAVE_LSTAT.
|
||||
|
||||
* filetools.C (LyXReadLink): protect the code with
|
||||
#ifdef HAVE_READLINK.
|
||||
|
||||
2005-01-01 Kayvan Sylvan <kayvan@sylvan.com>
|
||||
|
||||
* os_win32.C (internal_path): remove the call to MakeLatexName as
|
||||
|
@ -10,12 +10,14 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
//#include <sys/types.h>
|
||||
//#include <sys/stat.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include "FileInfo.h"
|
||||
#include "LAssert.h"
|
||||
#include "lstrings.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <cerrno>
|
||||
|
||||
#if !S_IRUSR
|
||||
# if S_IREAD
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
@ -1247,6 +1247,7 @@ string const MakeDisplayPath(string const & path, unsigned int threshold)
|
||||
|
||||
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, string & link, bool resolve)
|
||||
else
|
||||
link = linkbuffer;
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user