00001 #ifndef CLASSLIB_FILE_ACL_H
00002 # define CLASSLIB_FILE_ACL_H
00003
00004
00005
00006 # include "classlib/utils/UserInfo.h"
00007 # undef unix // FIXME: visible on too many systems
00008
00009 namespace lat {
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 class FileAcl
00020 {
00021 public:
00022
00023
00024
00025 enum {
00026 ReadBit = 4,
00027 WriteBit = 2,
00028 ExecBit = 1,
00029
00030 OwnerOffset = 6,
00031 OwnerBits = 7 << OwnerOffset,
00032 OwnerRead = ReadBit << OwnerOffset,
00033 OwnerWrite = WriteBit << OwnerOffset,
00034 OwnerExec = ExecBit << OwnerOffset,
00035
00036 GroupOffset = 3,
00037 GroupBits = 7 << GroupOffset,
00038 GroupRead = ReadBit << GroupOffset,
00039 GroupWrite = WriteBit << GroupOffset,
00040 GroupExec = ExecBit << GroupOffset,
00041
00042 OtherOffset = 0,
00043 OtherBits = 7 << OtherOffset,
00044 OtherRead = ReadBit << OtherOffset,
00045 OtherWrite = WriteBit << OtherOffset,
00046 OtherExec = ExecBit << OtherOffset,
00047
00048 ReadBits = OwnerRead | GroupRead | OtherRead,
00049 WriteBits = OwnerWrite | GroupWrite | OtherWrite,
00050 ExecBits = OwnerExec | GroupExec | OtherExec,
00051
00052 Sticky = 1 << 10,
00053 SetGID = 1 << 11,
00054 SetUID = 1 << 12,
00055
00056
00057 Hidden = 1 << 13,
00058 System = 1 << 14,
00059 Archive = 1 << 15,
00060
00061 Encrypted = 1 << 16,
00062 NotIndexed = 1 << 17,
00063 Offline = 1 << 18,
00064 Temporary = 1 << 19
00065 };
00066
00067 FileAcl (void);
00068 FileAcl (int unixPerms, UID uid = UID (-1), GID gid = GID (-1));
00069
00070
00071
00072
00073 UID owner (void) const;
00074 void owner (UID uid);
00075 GID group (void) const;
00076 void group (GID gid);
00077
00078 int portable (void) const;
00079 int addPortable (int mask);
00080
00081 int unix (void) const;
00082 int addUnix (int mask);
00083
00084 bool readonly (void) const;
00085
00086 #ifdef _WIN32
00087
00088
00089 #else
00090 int native (void) const;
00091 int addNative (int mode);
00092 #endif
00093
00094 private:
00095 UID m_owner;
00096 GID m_group;
00097 int m_perms;
00098 };
00099
00100
00101
00102
00103 }
00104 #endif // CLASSLIB_FILE_ACL_H