1
/* Copyright (C) 2000 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include "mysys_priv.h"
18
#include "mysys_err.h"
25
** Read | write on file (umask value)
26
** Read & Write on open file
31
File my_create(const char *FileName, int CreateFlags, int access_flags,
35
DBUG_ENTER("my_create");
36
DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d",
37
FileName, CreateFlags, access_flags, MyFlags));
39
#if !defined(NO_OPEN_3)
40
fd = open((char *) FileName, access_flags | O_CREAT,
41
CreateFlags ? CreateFlags : my_umask);
43
fd = open(FileName, access_flags);
46
if ((MyFlags & MY_SYNC_DIR) && (fd >=0) &&
47
my_sync_dir_by_file(FileName, MyFlags))
49
my_close(fd, MyFlags);
53
rc= my_register_filename(fd, FileName, FILE_BY_CREATE,
54
EE_CANTCREATEFILE, MyFlags);
56
my_register_filename() may fail on some platforms even if the call to
57
*open() above succeeds. In this case, don't leave the stale file because
58
callers assume the file to not exist if my_create() fails, so they don't
61
if (unlikely(fd >= 0 && rc < 0))
64
my_delete(FileName, MyFlags);