Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-11 08:33:55

0001 // Created on: 2018-03-15
0002 // Created by: Stephan GARNAUD (ARM)
0003 // Copyright (c) 1998-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _OSD_Protection_HeaderFile
0018 #define _OSD_Protection_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <OSD_SingleProtection.hxx>
0025 
0026 //! This  class provides data to manage file protection
0027 //! Example:These rights are treated in a system dependent manner :
0028 //! On UNIX you have User,Group and Other rights
0029 //! On VMS  you have Owner,Group,World and System rights
0030 //! An automatic conversion is done between OSD and UNIX/VMS.
0031 //!
0032 //! OSD VMS UNIX
0033 //! User     Owner   User
0034 //! Group    Group   Group
0035 //! World    World   Other
0036 //! System   System  (combined with Other)
0037 //!
0038 //! When you use System protection on UNIX you must know that
0039 //! Other rights and System rights are inclusively "ORed".
0040 //! So Other with only READ access and System with WRITE access
0041 //! will produce on UNIX Other with READ and WRITE access.
0042 //!
0043 //! This choice comes from the fact that ROOT can't be considered
0044 //! as member of the group nor as user. So it is considered as Other.
0045 class OSD_Protection
0046 {
0047 public:
0048   DEFINE_STANDARD_ALLOC
0049 
0050   //! Initializes global access rights as follows
0051   //!
0052   //! User   : Read Write
0053   //! System : Read Write
0054   //! Group  : Read
0055   //! World  : Read
0056   Standard_EXPORT OSD_Protection();
0057 
0058   //! Sets values of fields
0059   Standard_EXPORT OSD_Protection(const OSD_SingleProtection System,
0060                                  const OSD_SingleProtection User,
0061                                  const OSD_SingleProtection Group,
0062                                  const OSD_SingleProtection World);
0063 
0064   //! Retrieves values of fields
0065   Standard_EXPORT void Values(OSD_SingleProtection& System,
0066                               OSD_SingleProtection& User,
0067                               OSD_SingleProtection& Group,
0068                               OSD_SingleProtection& World);
0069 
0070   //! Sets values of fields
0071   Standard_EXPORT void SetValues(const OSD_SingleProtection System,
0072                                  const OSD_SingleProtection User,
0073                                  const OSD_SingleProtection Group,
0074                                  const OSD_SingleProtection World);
0075 
0076   //! Sets protection of 'System'
0077   Standard_EXPORT void SetSystem(const OSD_SingleProtection priv);
0078 
0079   //! Sets protection of 'User'
0080   Standard_EXPORT void SetUser(const OSD_SingleProtection priv);
0081 
0082   //! Sets protection of 'Group'
0083   Standard_EXPORT void SetGroup(const OSD_SingleProtection priv);
0084 
0085   //! Sets protection of 'World'
0086   Standard_EXPORT void SetWorld(const OSD_SingleProtection priv);
0087 
0088   //! Gets protection of 'System'
0089   Standard_EXPORT OSD_SingleProtection System() const;
0090 
0091   //! Gets protection of 'User'
0092   Standard_EXPORT OSD_SingleProtection User() const;
0093 
0094   //! Gets protection of 'Group'
0095   Standard_EXPORT OSD_SingleProtection Group() const;
0096 
0097   //! Gets protection of 'World'
0098   Standard_EXPORT OSD_SingleProtection World() const;
0099 
0100   //! Add a right to a single protection.
0101   //! ex: aProt = RWD
0102   //! me.Add(aProt,X)  ->  aProt = RWXD
0103   Standard_EXPORT void Add(OSD_SingleProtection& aProt, const OSD_SingleProtection aRight);
0104 
0105   //! Subtract a right to a single protection.
0106   //! ex: aProt = RWD
0107   //! me.Sub(aProt,RW) ->  aProt = D
0108   //! But me.Sub(aProt,RWX) is also valid and gives same result.
0109   Standard_EXPORT void Sub(OSD_SingleProtection& aProt, const OSD_SingleProtection aRight);
0110 
0111   friend class OSD_FileNode;
0112   friend class OSD_File;
0113   friend class OSD_Directory;
0114 
0115 protected:
0116 private:
0117   //! Returns System dependent access rights
0118   //! this is a private method.
0119   Standard_EXPORT Standard_Integer Internal() const;
0120 
0121   OSD_SingleProtection s;
0122   OSD_SingleProtection u;
0123   OSD_SingleProtection g;
0124   OSD_SingleProtection w;
0125 };
0126 
0127 #endif // _OSD_Protection_HeaderFile