From 9508a23a1ba41b9ff7928982dd48d53d21b12c4e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 10 Feb 2010 11:38:41 +0000 Subject: [PATCH] Move wxPosixPermissions definition from wx/file.h to wx/filefn.h. This fixes compilation with wxUSE_FILE=0 as wxFileName::Mkdir() still uses these constants but their definitions were not available in this case. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63456 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/file.h | 49 -------------------------------------- include/wx/filefn.h | 47 +++++++++++++++++++++++++++++++++++- interface/wx/file.h | 53 ----------------------------------------- interface/wx/filefn.h | 55 ++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 100 insertions(+), 104 deletions(-) diff --git a/include/wx/file.h b/include/wx/file.h index 23e46278a7..f630f831f5 100644 --- a/include/wx/file.h +++ b/include/wx/file.h @@ -21,55 +21,6 @@ #include "wx/filefn.h" #include "wx/strconv.h" -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// 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 -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 synonyms 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 // diff --git a/include/wx/filefn.h b/include/wx/filefn.h index 1699933e4f..2f05143559 100644 --- a/include/wx/filefn.h +++ b/include/wx/filefn.h @@ -134,6 +134,51 @@ enum wxFileKind wxFILE_KIND_PIPE // a pipe }; +// 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 +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 synonyms 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) +}; + // ---------------------------------------------------------------------------- // declare our versions of low level file functions: some compilers prepend // underscores to the usual names, some also have Unicode versions of them @@ -666,7 +711,7 @@ WXDLLIMPEXP_BASE wxString wxGetCwd(); WXDLLIMPEXP_BASE bool wxSetWorkingDirectory(const wxString& d); // Make directory -WXDLLIMPEXP_BASE bool wxMkdir(const wxString& dir, int perm = 0777); +WXDLLIMPEXP_BASE bool wxMkdir(const wxString& dir, int perm = wxS_DIR_DEFAULT); // Remove directory. Flags reserved for future use. WXDLLIMPEXP_BASE bool wxRmdir(const wxString& dir, int flags = 0); diff --git a/interface/wx/file.h b/interface/wx/file.h index 10efe6534d..fd4a44b827 100644 --- a/interface/wx/file.h +++ b/interface/wx/file.h @@ -7,59 +7,6 @@ ///////////////////////////////////////////////////////////////////////////// -/** - 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. -*/ -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 wxTempFile diff --git a/interface/wx/filefn.h b/interface/wx/filefn.h index 1080f8f540..9659221bdb 100644 --- a/interface/wx/filefn.h +++ b/interface/wx/filefn.h @@ -358,6 +358,59 @@ bool wxConcatFiles(const wxString& file1, */ bool wxRemoveFile(const wxString& file); +/** + File permission bit names. + + We define these constants in wxWidgets because S_IREAD &c are not standard. + However, we do assume that the values correspond to the Unix umask bits. +*/ +enum wxPosixPermissions +{ + /// Standard POSIX names for these permission flags with "wx" prefix. + //@{ + 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 synonyms 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) +}; + /** Makes the directory @a dir, returning @true if successful. @@ -366,7 +419,7 @@ bool wxRemoveFile(const wxString& file); @header{wx/filefn.h} */ -bool wxMkdir(const wxString& dir, int perm = 0777); +bool wxMkdir(const wxString& dir, int perm = wxS_DIR_DEFAULT); /** Removes the directory @a dir, returning @true if successful. Does not work -- 2.45.2