From 1a33c3ba91c23c1b143ce2d44a7d23e31220cf30 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Thu, 1 Apr 1999 12:01:47 +0000
Subject: [PATCH] wxMkDir() has 'perm' argument

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2020 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/function.tex |  5 ++++-
 include/wx/filefn.h        |  2 +-
 src/common/filefn.cpp      | 27 +++++++++++++++------------
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex
index fd7c4ac06d..670204264c 100644
--- a/docs/latex/wx/function.tex
+++ b/docs/latex/wx/function.tex
@@ -161,10 +161,13 @@ with wildcard characters. See \helpref{wxIsWild}{wxiswild}.
 
 \membersection{::wxMkdir}
 
-\func{bool}{wxMkdir}{\param{const wxString\& }{dir}}
+\func{bool}{wxMkdir}{\param{const wxString\& }{dir}, \param{int }{perm = 0777}}
 
 Makes the directory {\it dir}, returning TRUE if successful.
 
+{\it perm} is the access mask for the directory for the systems on which it is
+supported (Unix) and doesn't have effect for the other ones.
+
 \membersection{::wxRemoveFile}
 
 \func{bool}{wxRemoveFile}{\param{const wxString\& }{file}}
diff --git a/include/wx/filefn.h b/include/wx/filefn.h
index 777973aabd..40cd290df8 100644
--- a/include/wx/filefn.h
+++ b/include/wx/filefn.h
@@ -153,7 +153,7 @@ WXDLLEXPORT wxString wxGetCwd();
 WXDLLEXPORT bool wxSetWorkingDirectory(const wxString& d);
 
 // Make directory
-WXDLLEXPORT bool wxMkdir(const wxString& dir);
+WXDLLEXPORT bool wxMkdir(const wxString& dir, int perm = 0777);
 
 // Remove directory. Flags reserved for future use.
 WXDLLEXPORT bool wxRmdir(const wxString& dir, int flags = 0);
diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp
index 939097401f..21e33dc94b 100644
--- a/src/common/filefn.cpp
+++ b/src/common/filefn.cpp
@@ -980,21 +980,24 @@ bool wxRemoveFile(const wxString& file)
   return (flag == 0) ;
 }
 
-bool wxMkdir(const wxString& dir)
+bool wxMkdir(const wxString& dir, int perm)
 {
-#if defined(__WXSTUBS__)
-  return FALSE;
-#elif defined(__VMS__)
-        return FALSE;
-#elif defined( __WXMAC__ )
-  strcpy( gwxMacFileName , dir ) ;
-  wxUnix2MacFilename( gwxMacFileName ) ;
-  return (mkdir(gwxMacFileName , 0 ) == 0);
-#elif (defined(__GNUWIN32__) && !defined(__MINGW32__)) || !defined(__WXMSW__)
-  return (mkdir (WXSTRINGCAST dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0);
+#if defined( __WXMAC__ )
+    strcpy( gwxMacFileName , dir ) ;
+    wxUnix2MacFilename( gwxMacFileName ) ;
+    const char *dirname = gwxMacFileName;
 #else
-  return (mkdir(WXSTRINGCAST dir) == 0);
+    const char *dirname = dir.c_str();
 #endif
+
+    if ( mkdir(dirname, perm) != 0 )
+    {
+        wxLogSysError(_("Directory '%s' couldn't be created"), dirname);
+
+        return FALSE;
+    }
+
+    return TRUE;
 }
 
 bool wxRmdir(const wxString& dir, int WXUNUSED(flags))
-- 
2.50.0

