]> git.saurik.com Git - wxWidgets.git/commitdiff
add wxPosixPermissions enumeration; it provides more readable synonims for wxS_I...
authorFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Sat, 27 Sep 2008 10:28:43 +0000 (10:28 +0000)
committerFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Sat, 27 Sep 2008 10:28:43 +0000 (10:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55909 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/file.h
include/wx/filename.h

index 6d39f01bda96cc7dad3db58d1d8b0bd2293b6172..df901520ef7b90f266053b5261a6b195515e9dbd 100644 (file)
 
 // we redefine these constants here because S_IREAD &c are _not_ standard
 // however, we do assume that the values correspond to the Unix umask bits
-#define wxS_IRUSR 00400
-#define wxS_IWUSR 00200
-#define wxS_IXUSR 00100
-
-#define wxS_IRGRP 00040
-#define wxS_IWGRP 00020
-#define wxS_IXGRP 00010
-
-#define wxS_IROTH 00004
-#define wxS_IWOTH 00002
-#define wxS_IXOTH 00001
-
-// default mode for the new files: allow reading/writing them to everybody but
-// the effective file mode will be set after anding this value with umask and
-// so won't include wxS_IW{GRP,OTH} for the default 022 umask value
-#define wxS_DEFAULT \
-    (wxS_IRUSR | wxS_IWUSR | wxS_IRGRP | wxS_IWGRP | wxS_IROTH | wxS_IWOTH)
+enum wxPosixPermissions
+{
+    // standard Posix names for these permission flags:
+    wxS_IRUSR = 00400,
+    wxS_IWUSR = 00200,
+    wxS_IXUSR = 00100,
+
+    wxS_IRGRP = 00040,
+    wxS_IWGRP = 00020,
+    wxS_IXGRP = 00010,
+
+    wxS_IROTH = 00004,
+    wxS_IWOTH = 00002,
+    wxS_IXOTH = 00001,
+
+    // longer but more readable synonims for the constants above:
+    wxPOSIX_USER_READ = wxS_IRUSR,
+    wxPOSIX_USER_WRITE = wxS_IWUSR,
+    wxPOSIX_USER_EXECUTE = wxS_IXUSR,
+
+    wxPOSIX_GROUP_READ = wxS_IRGRP,
+    wxPOSIX_GROUP_WRITE = wxS_IWGRP,
+    wxPOSIX_GROUP_EXECUTE = wxS_IXGRP,
+
+    wxPOSIX_OTHERS_READ = wxS_IROTH,
+    wxPOSIX_OTHERS_WRITE = wxS_IWOTH,
+    wxPOSIX_OTHERS_EXECUTE = wxS_IXOTH,
+
+    // default mode for the new files: allow reading/writing them to everybody but
+    // the effective file mode will be set after anding this value with umask and
+    // so won't include wxS_IW{GRP,OTH} for the default 022 umask value
+    wxS_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | \
+                   wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | \
+                   wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE),
+
+    // default mode for the new directories (see wxFileName::Mkdir): allow
+    // reading/writing/executing them to everybody, but just like wxS_DEFAULT
+    // the effective directory mode will be set after anding this value with umask
+    wxS_DIR_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | wxPOSIX_USER_EXECUTE | \
+                       wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | wxPOSIX_GROUP_EXECUTE | \
+                       wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE | wxPOSIX_OTHERS_EXECUTE)
+};
 
 // ----------------------------------------------------------------------------
 // class wxFile: raw file IO
index 347b0ab621e7e4588a4dcb3a4535af39145db186..2cc5c75b8de7ab2f50a22f5a112fc1150fe9aec5 100644 (file)
@@ -28,6 +28,7 @@
 #include "wx/datetime.h"
 #include "wx/intl.h"
 #include "wx/longlong.h"
+#include "wx/file.h"
 
 #if wxUSE_FILE
 class WXDLLIMPEXP_FWD_BASE wxFile;
@@ -308,8 +309,8 @@ public:
 #endif // wxUSE_FFILE
 
     // directory creation and removal.
-    bool Mkdir( int perm = 0777, int flags = 0);
-    static bool Mkdir( const wxString &dir, int perm = 0777, int flags = 0 );
+    bool Mkdir( int perm = wxS_DIR_DEFAULT, int flags = 0);
+    static bool Mkdir( const wxString &dir, int perm = wxS_DIR_DEFAULT, int flags = 0 );
 
     bool Rmdir();
     static bool Rmdir( const wxString &dir );