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);
43 /// Query a new file descriptor
44 FileInfo& newFile(int fildes);
46 /// Returns a character describing file type (ls -F)
47 char const * typeIndicator() const;
49 /// File protection mode
50 mode_t getMode() const;
52 /// Get "preferred" block size for efficient file system I/O
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;
76 /// Total file size in bytes
77 off_t getSize() const;
79 /// Number of hard links
80 nlink_t getNumberOfLinks() const;
88 /// Is the file information correct? Did the query succeed?
93 rperm = R_OK, // test for read permission
94 wperm = W_OK, // test for write permission
95 xperm = X_OK, // test for execute (search) permission
96 eperm = F_OK // test for existence of file
98 /// Test whether the current user has a given set of permissions
100 /// Is the file writable for the current user?
101 bool writable() { return access(FileInfo::wperm); }
102 /// Is the file readable for the current user?
103 bool readable() { return access(FileInfo::rperm); }
104 /// Is the file executable for the current user?
105 bool executable() { return access(FileInfo::xperm); }
106 /// Does the file exist?
107 bool exist() { return access(FileInfo::eperm); }
111 bool isRegular() const;
117 bool isBlock() const;
121 bool isSocket() const;
123 int getError() const;