2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 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. */
33 FileInfo(string const & path, bool link = false);
40 FileInfo & newFile(string const & path, bool link = false);
42 /// Query a new file descriptor
43 FileInfo & newFile(int fildes);
45 /// Returns a character describing file type (ls -F)
46 char const * typeIndicator() const;
48 /// File protection mode
49 mode_t getMode() const;
51 /// Get "preferred" block size for efficient file system I/O
52 long getBlockSize() const;
54 /// Constructs standard mode string (ls style)
55 void modeString(char * szString) const;
57 /// returns a letter describing a file type (ls style)
58 char typeLetter() const;
60 /// builds 'rwx' string describing file access rights
61 void flagRWX(unsigned short i, char * szString) const;
63 /// updates mode string to match suid/sgid/sticky bits
64 void setSticky(char * szString) const;
67 time_t getModificationTime() const;
70 time_t getAccessTime() const;
73 time_t getStatusChangeTime() const;
75 /// Total file size in bytes
76 off_t getSize() const;
78 /// Number of hard links
79 nlink_t getNumberOfLinks() const;
87 /// Is the file information correct? Did the query succeed?
92 rperm = R_OK, // test for read permission
93 wperm = W_OK, // test for write permission
94 xperm = X_OK, // test for execute (search) permission
95 eperm = F_OK // test for existence of file
97 /// Test whether the current user has a given set of permissions
99 /// Is the file writable for the current user?
100 bool writable() { return access(FileInfo::wperm); }
101 /// Is the file readable for the current user?
102 bool readable() { return access(FileInfo::rperm); }
103 /// Is the file executable for the current user?
104 bool executable() { return access(FileInfo::xperm); }
105 /// Does the file exist?
106 bool exist() { return access(FileInfo::eperm); }
110 bool isRegular() const;
116 bool isBlock() const;
120 bool isSocket() const;
122 int getError() const;