]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileInfo.C
fix typo that put too many include paths for most people
[lyx.git] / src / support / FileInfo.C
index baa460d493644167e2d495a185db3ca12316e7b2..032174aa3a56040d980b4cf0f65af02f7492e4b0 100644 (file)
@@ -1,9 +1,8 @@
-// -*- C++ -*-
 /* This file is part of
  * ======================================================
- * 
+ *
  *           LyX, The Document Processor
- *        
+ *
  *           Copyright 1995 Matthias Ettrich
  *           Copyright 1995-2001 The LyX Team.
  *
@@ -20,6 +19,7 @@
 
 #include <cerrno>
 #include "FileInfo.h"
+#include "LAssert.h"
 
 #if !S_IRUSR
 # if S_IREAD
@@ -56,7 +56,7 @@
 #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)
@@ -87,7 +87,7 @@
 #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>
@@ -97,7 +97,7 @@
 #include <sys/sysmacros.h>
 #define HAVE_MAJOR
 #endif
-#ifdef major           
+#ifdef major
 #define HAVE_MAJOR
 #endif
 
@@ -152,7 +152,7 @@ void FileInfo::dostat(bool link)
 FileInfo & FileInfo::newFile(string const & path, bool link)
 {
        fname = path;
-       
+
        status = 0;
        err = NoErr;
 
@@ -175,6 +175,8 @@ FileInfo & FileInfo::newFile(int fildes)
 // 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 ("@");
@@ -193,6 +195,8 @@ char const * FileInfo::typeIndicator() const
 
 mode_t FileInfo::getMode() const
 {
+       lyx::Assert(isOK());
+
        return buf.st_mode;
 }
 
@@ -212,6 +216,8 @@ void FileInfo::modeString(char * szString) const
 // should not be in FileInfo
 char FileInfo::typeLetter() const
 {
+       lyx::Assert(isOK());
+
 #ifdef S_ISBLK
        if (S_ISBLK(buf.st_mode)) return 'b';
 #endif
@@ -249,6 +255,8 @@ void FileInfo::flagRWX(mode_t i, char * szString) const
 // 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';
@@ -272,42 +280,49 @@ void FileInfo::setSticky(char * szString) const
 
 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;
 }
 
@@ -329,42 +344,49 @@ bool FileInfo::isOK() const
 
 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
@@ -378,7 +400,7 @@ 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 {
@@ -387,6 +409,3 @@ bool FileInfo::access(int p) const
                return false;
        }
 }
-
-
-