| 1 | /* Copyright (c) 2000, 2001, 2006 MySQL AB |
| 2 | Use is subject to license terms |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by |
| 6 | the Free Software Foundation; version 2 of the License. |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program; if not, write to the Free Software |
| 15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ |
| 16 | |
| 17 | #include "mysys_priv.h" |
| 18 | #include "mysys_err.h" |
| 19 | #include <sys/types.h> |
| 20 | #include <sys/stat.h> |
| 21 | #ifdef __WIN__ |
| 22 | #include <direct.h> |
| 23 | #endif |
| 24 | |
| 25 | int my_mkdir(const char *dir, int Flags, myf MyFlags) |
| 26 | { |
| 27 | DBUG_ENTER("my_dir" ); |
| 28 | DBUG_PRINT("enter" ,("dir: %s" ,dir)); |
| 29 | |
| 30 | #if defined(__WIN__) |
| 31 | if (mkdir((char*) dir)) |
| 32 | #else |
| 33 | if (mkdir((char*) dir, Flags & my_umask_dir)) |
| 34 | #endif |
| 35 | { |
| 36 | my_errno=errno; |
| 37 | DBUG_PRINT("error" ,("error %d when creating direcory %s" ,my_errno,dir)); |
| 38 | if (MyFlags & (MY_FFNF | MY_FAE | MY_WME)) |
| 39 | my_error(EE_CANT_MKDIR, MYF(ME_BELL+ME_WAITTANG), dir, my_errno); |
| 40 | DBUG_RETURN(-1); |
| 41 | } |
| 42 | DBUG_RETURN(0); |
| 43 | } |
| 44 | |