~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/my_open.cc

  • Committer: Brian Aker
  • Date: 2010-04-05 23:46:43 UTC
  • Revision ID: brian@gaz-20100405234643-0he3xnj902rc70r8
Fixing tests to work with PBXT.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include "mysys/mysys_priv.h"
17
 
#include "mysys/mysys_err.h"
18
 
#include "my_dir.h"
19
 
 
20
 
#include <errno.h>
21
 
#include <stdlib.h>
22
 
#include <string.h>
 
16
#include "config.h"
 
17
 
 
18
#include "drizzled/internal/my_sys.h"
 
19
#include "drizzled/error.h"
 
20
 
 
21
#include <fcntl.h>
 
22
 
 
23
#include <cerrno>
 
24
#include <cstdlib>
 
25
#include <cstring>
 
26
 
 
27
 
 
28
namespace drizzled
 
29
{
 
30
namespace internal
 
31
{
23
32
 
24
33
/*
25
34
  Open a file
31
40
      MyFlags   Special flags
32
41
 
33
42
  RETURN VALUE
34
 
    File descriptor
 
43
    int descriptor
35
44
*/
36
45
 
37
 
File my_open(const char *FileName, int Flags, myf MyFlags)
 
46
int my_open(const char *FileName, int Flags, myf MyFlags)
38
47
                                /* Path-name of file */
39
48
                                /* Read | write .. */
40
49
                                /* Special flags */
41
50
{
42
 
  File fd;
 
51
  int fd;
43
52
 
44
53
#if !defined(NO_OPEN_3)
45
54
  fd = open(FileName, Flags, my_umask); /* Normal unix */
61
70
 
62
71
*/
63
72
 
64
 
int my_close(File fd, myf MyFlags)
 
73
int my_close(int fd, myf MyFlags)
65
74
{
66
75
  int err;
67
76
 
72
81
 
73
82
  if (err)
74
83
  {
75
 
    my_errno=errno;
 
84
    errno=errno;
76
85
    if (MyFlags & (MY_FAE | MY_WME))
77
86
      my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG), "unknown", errno);
78
87
  }
79
 
  my_file_opened--;
80
88
 
81
89
  return(err);
82
90
} /* my_close */
99
107
 
100
108
*/
101
109
 
102
 
File my_register_filename(File fd, const char *FileName, uint32_t error_message_number, myf MyFlags)
 
110
int my_register_filename(int fd, const char *FileName, uint32_t error_message_number, myf MyFlags)
103
111
{
104
112
  if ((int) fd >= 0)
105
113
  {
106
 
    my_file_opened++;
107
 
    my_file_total_opened++;
108
 
 
109
114
    return fd;
110
115
  }
111
116
  else
112
 
    my_errno= errno;
 
117
    errno= errno;
113
118
 
114
119
  if (MyFlags & (MY_FFNF | MY_FAE | MY_WME))
115
120
  {
116
 
    if (my_errno == EMFILE)
 
121
    if (errno == EMFILE)
117
122
      error_message_number= EE_OUT_OF_FILERESOURCES;
118
123
    my_error(error_message_number, MYF(ME_BELL+ME_WAITTANG),
119
 
             FileName, my_errno);
 
124
             FileName, errno);
120
125
  }
121
126
  return -1;
122
127
}
 
128
 
 
129
} /* namespace internal */
 
130
} /* namespace drizzled */