42cf5bc1 |
1 | // Created on: 2018-03-15 |
2 | // Created by: Stephan GARNAUD (ARM) |
3 | // Copyright (c) 1998-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _OSD_Protection_HeaderFile |
18 | #define _OSD_Protection_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <OSD_SingleProtection.hxx> |
42cf5bc1 |
25 | |
26 | |
27 | //! This class provides data to manage file protection |
28 | //! Example:These rights are treated in a system dependent manner : |
29 | //! On UNIX you have User,Group and Other rights |
30 | //! On VMS you have Owner,Group,World and System rights |
31 | //! An automatic conversion is done between OSD and UNIX/VMS. |
32 | //! |
33 | //! OSD VMS UNIX |
34 | //! User Owner User |
35 | //! Group Group Group |
36 | //! World World Other |
37 | //! System System (combined with Other) |
38 | //! |
39 | //! When you use System protection on UNIX you must know that |
40 | //! Other rights and System rights are inclusively "ORed". |
41 | //! So Other with only READ access and System with WRITE access |
42 | //! will produce on UNIX Other with READ and WRITE access. |
43 | //! |
44 | //! This choice comes from the fact that ROOT can't be considered |
45 | //! as member of the group nor as user. So it is considered as Other. |
46 | class OSD_Protection |
47 | { |
48 | public: |
49 | |
50 | DEFINE_STANDARD_ALLOC |
51 | |
52 | |
53 | //! Initializes global access rights as follows |
54 | //! |
55 | //! User : Read Write |
56 | //! System : Read Write |
57 | //! Group : Read |
58 | //! World : Read |
59 | Standard_EXPORT OSD_Protection(); |
60 | |
61 | //! Sets values of fields |
62 | Standard_EXPORT OSD_Protection(const OSD_SingleProtection System, const OSD_SingleProtection User, const OSD_SingleProtection Group, const OSD_SingleProtection World); |
63 | |
64 | //! Retrieves values of fields |
65 | Standard_EXPORT void Values (OSD_SingleProtection& System, OSD_SingleProtection& User, OSD_SingleProtection& Group, OSD_SingleProtection& World); |
66 | |
67 | //! Sets values of fields |
68 | Standard_EXPORT void SetValues (const OSD_SingleProtection System, const OSD_SingleProtection User, const OSD_SingleProtection Group, const OSD_SingleProtection World); |
69 | |
70 | //! Sets protection of 'System' |
71 | Standard_EXPORT void SetSystem (const OSD_SingleProtection priv); |
72 | |
73 | //! Sets protection of 'User' |
74 | Standard_EXPORT void SetUser (const OSD_SingleProtection priv); |
75 | |
76 | //! Sets protection of 'Group' |
77 | Standard_EXPORT void SetGroup (const OSD_SingleProtection priv); |
78 | |
79 | //! Sets protection of 'World' |
80 | Standard_EXPORT void SetWorld (const OSD_SingleProtection priv); |
81 | |
82 | //! Gets protection of 'System' |
83 | Standard_EXPORT OSD_SingleProtection System() const; |
84 | |
85 | //! Gets protection of 'User' |
86 | Standard_EXPORT OSD_SingleProtection User() const; |
87 | |
88 | //! Gets protection of 'Group' |
89 | Standard_EXPORT OSD_SingleProtection Group() const; |
90 | |
91 | //! Gets protection of 'World' |
92 | Standard_EXPORT OSD_SingleProtection World() const; |
93 | |
94 | //! Add a right to a single protection. |
95 | //! ex: aProt = RWD |
96 | //! me.Add(aProt,X) -> aProt = RWXD |
97 | Standard_EXPORT void Add (OSD_SingleProtection& aProt, const OSD_SingleProtection aRight); |
98 | |
99 | //! Subtract a right to a single protection. |
100 | //! ex: aProt = RWD |
101 | //! me.Sub(aProt,RW) -> aProt = D |
102 | //! But me.Sub(aProt,RWX) is also valid and gives same result. |
103 | Standard_EXPORT void Sub (OSD_SingleProtection& aProt, const OSD_SingleProtection aRight); |
104 | |
105 | |
106 | friend class OSD_FileNode; |
107 | friend class OSD_File; |
108 | friend class OSD_Directory; |
109 | |
110 | |
111 | protected: |
112 | |
113 | |
114 | |
115 | |
116 | |
117 | private: |
118 | |
119 | |
120 | //! Returns System dependent access rights |
121 | //! this is a private method. |
122 | Standard_EXPORT Standard_Integer Internal() const; |
123 | |
124 | |
125 | OSD_SingleProtection s; |
126 | OSD_SingleProtection u; |
127 | OSD_SingleProtection g; |
128 | OSD_SingleProtection w; |
129 | |
130 | |
131 | }; |
132 | |
133 | |
134 | |
135 | |
136 | |
137 | |
138 | |
139 | #endif // _OSD_Protection_HeaderFile |