1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
3
This library is free software; you can redistribute it and/or
4
modify it under the terms of the GNU Library General Public
5
License as published by the Free Software Foundation; either
6
version 2 of the License, or (at your option) any later version.
8
This library 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 GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public
14
License along with this library; if not, write to the Free
15
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19
#include "mysys_priv.h"
20
#include "mysys_err.h"
22
#if defined(MSDOS) || defined(__WIN__)
28
File my_open(const char *FileName, int Flags, myf MyFlags)
29
/* Path-name of file */
34
DBUG_ENTER("my_open");
35
DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d",
36
FileName, Flags, MyFlags));
37
#if defined(MSDOS) || defined(__WIN__)
39
fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO);
41
fd = open((my_string) FileName, Flags | O_BINARY);
42
#elif !defined(NO_OPEN_3)
43
fd = open(FileName, Flags, 0); /* Normal unix */
45
fd = open((my_string) FileName, Flags);
50
if ((int) fd >= MY_NFILE)
51
DBUG_RETURN(fd); /* safeguard */
52
pthread_mutex_lock(&THR_LOCK_open);
53
if ((my_file_info[fd].name = (char*) my_strdup(FileName,MyFlags)))
56
my_file_info[fd].type = FILE_BY_OPEN;
57
pthread_mutex_unlock(&THR_LOCK_open);
58
DBUG_PRINT("exit",("fd: %d",fd));
61
pthread_mutex_unlock(&THR_LOCK_open);
62
(void) my_close(fd,MyFlags);
67
DBUG_PRINT("error",("Got error %d on open",my_errno));
68
if (MyFlags & (MY_FFNF | MY_FAE | MY_WME))
69
my_error(EE_FILENOTFOUND, MYF(ME_BELL+ME_WAITTANG), FileName,my_errno);
76
int my_close(File fd, myf MyFlags)
79
DBUG_ENTER("my_close");
80
DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags));
82
pthread_mutex_lock(&THR_LOCK_open);
83
if ((err = close(fd)) != 0)
86
if (MyFlags & (MY_FAE | MY_WME))
87
my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG),my_filename(fd),errno);
89
if ((uint) fd < MY_NFILE && my_file_info[fd].type != UNOPEN)
92
my_free(my_file_info[fd].name, MYF(0));
93
my_file_info[fd].type = UNOPEN;
95
pthread_mutex_unlock(&THR_LOCK_open);