-// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 The LyX Team.
+ * Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
#pragma implementation
#endif
-#include <sys/types.h>
-#include <sys/stat.h>
+//#include <sys/types.h>
+//#include <sys/stat.h>
+
#include <cerrno>
#include "FileInfo.h"
+#include "LAssert.h"
#if !S_IRUSR
# if S_IREAD
#undef S_ISNWK
#undef S_ISREG
#undef S_ISSOCK
-#endif
+#endif
#if !defined(S_ISBLK) && defined(S_IFBLK)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
#endif
-// Since major is a function on SVR4, we can't use `ifndef major'.
+// Since major is a function on SVR4, we can't use `ifndef major'.
// might want to put MAJOR_IN_MKDEV for SYSV
#ifdef MAJOR_IN_MKDEV
#include <sys/mkdev.h>
#include <sys/sysmacros.h>
#define HAVE_MAJOR
#endif
-#ifdef major
+#ifdef major
#define HAVE_MAJOR
#endif
FileInfo & FileInfo::newFile(string const & path, bool link)
{
fname = path;
-
+
status = 0;
err = NoErr;
// should not be in FileInfo
char const * FileInfo::typeIndicator() const
{
+ lyx::Assert(isOK());
+
if (S_ISDIR(buf.st_mode)) return ("/");
#ifdef S_ISLNK
if (S_ISLNK(buf.st_mode)) return ("@");
mode_t FileInfo::getMode() const
{
+ lyx::Assert(isOK());
+
return buf.st_mode;
}
// should not be in FileInfo
char FileInfo::typeLetter() const
{
+ lyx::Assert(isOK());
+
#ifdef S_ISBLK
if (S_ISBLK(buf.st_mode)) return 'b';
#endif
// should not be in FileInfo
-void FileInfo::flagRWX(unsigned short i, char * szString) const
+void FileInfo::flagRWX(mode_t i, char * szString) const
{
szString[0] = (i & S_IRUSR) ? 'r' : '-';
szString[1] = (i & S_IWUSR) ? 'w' : '-';
// should not be in FileInfo
void FileInfo::setSticky(char * szString) const
{
+ lyx::Assert(isOK());
+
#ifdef S_ISUID
if (buf.st_mode & S_ISUID) {
if (szString[3] != 'x') szString[3] = 'S';
time_t FileInfo::getModificationTime() const
{
+ lyx::Assert(isOK());
return buf.st_mtime;
}
time_t FileInfo::getAccessTime() const
{
+ lyx::Assert(isOK());
return buf.st_atime;
}
time_t FileInfo::getStatusChangeTime() const
{
+ lyx::Assert(isOK());
return buf.st_ctime;
}
nlink_t FileInfo::getNumberOfLinks() const
{
+ lyx::Assert(isOK());
return buf.st_nlink;
}
uid_t FileInfo::getUid() const
{
+ lyx::Assert(isOK());
return buf.st_uid;
}
gid_t FileInfo::getGid() const
{
+ lyx::Assert(isOK());
return buf.st_gid;
}
off_t FileInfo::getSize() const
{
+ lyx::Assert(isOK());
return buf.st_size;
}
bool FileInfo::isLink() const
{
+ lyx::Assert(isOK());
return S_ISLNK(buf.st_mode);
}
bool FileInfo::isRegular() const
{
+ lyx::Assert(isOK());
return S_ISREG(buf.st_mode);
}
bool FileInfo::isDir() const
{
+ lyx::Assert(isOK());
return S_ISDIR(buf.st_mode);
}
bool FileInfo::isChar() const
{
+ lyx::Assert(isOK());
return S_ISCHR(buf.st_mode);
}
bool FileInfo::isBlock() const
{
+ lyx::Assert(isOK());
return S_ISBLK(buf.st_mode);
}
bool FileInfo::isFifo() const
{
+ lyx::Assert(isOK());
return S_ISFIFO(buf.st_mode);
}
bool FileInfo::isSocket() const
{
+ lyx::Assert(isOK());
#ifdef S_ISSOCK
return S_ISSOCK(buf.st_mode);
#else
// should not be in FileInfo
-bool FileInfo::access(int p)
+bool FileInfo::access(int p) const
{
// if we don't have a filename we fail
if (fname.empty()) return false;
-
+
if (::access(fname.c_str(), p) == 0)
return true;
else {
return false;
}
}
-
-
-