0030403: Application Framework - Overwriting Big BinOcaf Files Does Not Reduce Their...
[occt.git] / src / OSD / OSD_Protection.hxx
CommitLineData
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>
25#include <Standard_Integer.hxx>
26class OSD_FileNode;
27class OSD_File;
28class OSD_Directory;
29
30
31//! This class provides data to manage file protection
32//! Example:These rights are treated in a system dependent manner :
33//! On UNIX you have User,Group and Other rights
34//! On VMS you have Owner,Group,World and System rights
35//! An automatic conversion is done between OSD and UNIX/VMS.
36//!
37//! OSD VMS UNIX
38//! User Owner User
39//! Group Group Group
40//! World World Other
41//! System System (combined with Other)
42//!
43//! When you use System protection on UNIX you must know that
44//! Other rights and System rights are inclusively "ORed".
45//! So Other with only READ access and System with WRITE access
46//! will produce on UNIX Other with READ and WRITE access.
47//!
48//! This choice comes from the fact that ROOT can't be considered
49//! as member of the group nor as user. So it is considered as Other.
50class OSD_Protection
51{
52public:
53
54 DEFINE_STANDARD_ALLOC
55
56
57 //! Initializes global access rights as follows
58 //!
59 //! User : Read Write
60 //! System : Read Write
61 //! Group : Read
62 //! World : Read
63 Standard_EXPORT OSD_Protection();
64
65 //! Sets values of fields
66 Standard_EXPORT OSD_Protection(const OSD_SingleProtection System, const OSD_SingleProtection User, const OSD_SingleProtection Group, const OSD_SingleProtection World);
67
68 //! Retrieves values of fields
69 Standard_EXPORT void Values (OSD_SingleProtection& System, OSD_SingleProtection& User, OSD_SingleProtection& Group, OSD_SingleProtection& World);
70
71 //! Sets values of fields
72 Standard_EXPORT void SetValues (const OSD_SingleProtection System, const OSD_SingleProtection User, const OSD_SingleProtection Group, const OSD_SingleProtection World);
73
74 //! Sets protection of 'System'
75 Standard_EXPORT void SetSystem (const OSD_SingleProtection priv);
76
77 //! Sets protection of 'User'
78 Standard_EXPORT void SetUser (const OSD_SingleProtection priv);
79
80 //! Sets protection of 'Group'
81 Standard_EXPORT void SetGroup (const OSD_SingleProtection priv);
82
83 //! Sets protection of 'World'
84 Standard_EXPORT void SetWorld (const OSD_SingleProtection priv);
85
86 //! Gets protection of 'System'
87 Standard_EXPORT OSD_SingleProtection System() const;
88
89 //! Gets protection of 'User'
90 Standard_EXPORT OSD_SingleProtection User() const;
91
92 //! Gets protection of 'Group'
93 Standard_EXPORT OSD_SingleProtection Group() const;
94
95 //! Gets protection of 'World'
96 Standard_EXPORT OSD_SingleProtection World() const;
97
98 //! Add a right to a single protection.
99 //! ex: aProt = RWD
100 //! me.Add(aProt,X) -> aProt = RWXD
101 Standard_EXPORT void Add (OSD_SingleProtection& aProt, const OSD_SingleProtection aRight);
102
103 //! Subtract a right to a single protection.
104 //! ex: aProt = RWD
105 //! me.Sub(aProt,RW) -> aProt = D
106 //! But me.Sub(aProt,RWX) is also valid and gives same result.
107 Standard_EXPORT void Sub (OSD_SingleProtection& aProt, const OSD_SingleProtection aRight);
108
109
110friend class OSD_FileNode;
111friend class OSD_File;
112friend class OSD_Directory;
113
114
115protected:
116
117
118
119
120
121private:
122
123
124 //! Returns System dependent access rights
125 //! this is a private method.
126 Standard_EXPORT Standard_Integer Internal() const;
127
128
129 OSD_SingleProtection s;
130 OSD_SingleProtection u;
131 OSD_SingleProtection g;
132 OSD_SingleProtection w;
133
134
135};
136
137
138
139
140
141
142
143#endif // _OSD_Protection_HeaderFile