2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-1999 The LyX Team.
10 * ======================================================*/
18 #include <sys/types.h>
23 /** Use objects of this class to get information about files. */
29 /** Get information about file.
30 If link is true, the information is about the link itself, not
31 the file that is obtained by tracing the links. */
32 FileInfo(string const & path, bool link = false);
41 FileInfo& newFile(string const & path, bool link = false);
44 FileInfo& newFile(int fildes);
46 /// returns a character describing file type (ls -F)
47 char const * typeIndicator() const;
50 mode_t getMode() const;
53 long getBlockSize() const;
55 /// constructs standard mode string (ls style)
56 void modeString(char * szString) const;
58 /// returns a letter describing a file type (ls style)
59 char typeLetter() const;
61 /// builds 'rwx' string describing file access rights
62 void flagRWX(unsigned short i, char * szString) const;
64 /// updates mode string to match suid/sgid/sticky bits
65 void setSticky(char * szString) const;
68 time_t getModificationTime() const;
71 time_t getAccessTime() const;
74 time_t getStatusChangeTime() const;
77 off_t getSize() const;
80 nlink_t getNumberOfLinks() const;
90 rperm = R_OK, // test for read permission
91 wperm = W_OK, // test for write permission
92 xperm = X_OK, // test for execute (search) permission
93 eperm = F_OK // test for existence of file
98 bool writable() { return access(FileInfo::wperm); }
100 bool readable() { return access(FileInfo::rperm); }
102 bool executable() { return access(FileInfo::xperm); }
104 bool exist() { return access(FileInfo::eperm); }
108 bool isRegular() const;
114 bool isBlock() const;
118 bool isSocket() const;
120 int getError() const;