~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000 MySQL AB
2
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.
6
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.
11
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 */
15
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
16
#include "config.h"
17
18
#include "drizzled/internal/my_sys.h"
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
19
20
#include <fcntl.h>
21
#include <errno.h>
22
1271.5.3 by Tim Penhey
change the include files
23
#include "drizzled/error.h"
685.1.3 by Monty Taylor
Turned off stdinc - and then fixed the carnage.
24
1 by brian
clean slate
25
	/*
26
	** Create a new file
27
	** Arguments:
28
	** Path-name of file
29
	** Read | write on file (umask value)
30
	** Read & Write on open file
31
	** Special flags
32
	*/
33
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
34
namespace drizzled
35
{
36
namespace internal
37
{
1 by brian
clean slate
38
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
39
int my_create(const char *FileName, int CreateFlags, int access_flags,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
40
              myf MyFlags)
1 by brian
clean slate
41
{
42
  int fd, rc;
43
44
#if !defined(NO_OPEN_3)
266.7.14 by Andy Lester
Removed unnecessary cast
45
  fd = open(FileName, access_flags | O_CREAT,
1 by brian
clean slate
46
	    CreateFlags ? CreateFlags : my_umask);
47
#else
48
  fd = open(FileName, access_flags);
49
#endif
50
51
  if ((MyFlags & MY_SYNC_DIR) && (fd >=0) &&
52
      my_sync_dir_by_file(FileName, MyFlags))
53
  {
54
    my_close(fd, MyFlags);
55
    fd= -1;
56
  }
57
1034.1.8 by Brian Aker
Remove locks around my_open(). Open file counts are now "best effort" (not
58
  rc= my_register_filename(fd, FileName, EE_CANTCREATEFILE, MyFlags);
1 by brian
clean slate
59
  /*
60
    my_register_filename() may fail on some platforms even if the call to
61
    *open() above succeeds. In this case, don't leave the stale file because
62
    callers assume the file to not exist if my_create() fails, so they don't
63
    do any cleanups.
64
  */
65
  if (unlikely(fd >= 0 && rc < 0))
66
  {
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
67
    int tmp= errno;
1 by brian
clean slate
68
    my_delete(FileName, MyFlags);
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
69
    errno= tmp;
1 by brian
clean slate
70
  }
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
71
51.3.20 by Jay Pipes
Phase 6 - Remove DBUG from mysys
72
  return(rc);
1 by brian
clean slate
73
} /* my_create */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
74
75
} /* namespace internal */
76
} /* namespace drizzled */