mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 10:31:54 +01:00
adfba203ff
make it return an error (except if certain errno), test this error in callers. Do a single my_sync_dir() in my_rename() if possible. include/my_global.h: better have a symbol name talking about the feature, use it in the code of the feature, and define the symbol once depending on the platform, rather than have the platform "tested" in the code of the feature several times. include/my_sys.h: my_sync_dir() now can return error mysys/my_create.c: my_sync_dir() can now return an error mysys/my_delete.c: my_sync_dir() can now return an error mysys/my_rename.c: my_sync_dir() can now return an error. Do a single sync if "from" and "to" are the same directory. #ifdef here to not even compile dirname_part() if useless. mysys/my_sync.c: more comments. A compilation error if no way to make my_sync() work (I guess we don't want to ship a binary which cannot do any sync at all; users of strange OSes compile from source and can remove the #error). my_sync_dir() now returns an error (except for certain errno values considered ok; EIO "input/output error" is not ok). sql/unireg.cc: my_sync_dir() now returns an error which must be tested
65 lines
1.9 KiB
C
65 lines
1.9 KiB
C
/* Copyright (C) 2000 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#include "mysys_priv.h"
|
|
#include <my_dir.h>
|
|
#include "mysys_err.h"
|
|
#include <errno.h>
|
|
#if defined(__WIN__)
|
|
#include <share.h>
|
|
#endif
|
|
|
|
/*
|
|
** Create a new file
|
|
** Arguments:
|
|
** Path-name of file
|
|
** Read | write on file (umask value)
|
|
** Read & Write on open file
|
|
** Special flags
|
|
*/
|
|
|
|
|
|
File my_create(const char *FileName, int CreateFlags, int access_flags,
|
|
myf MyFlags)
|
|
{
|
|
int fd;
|
|
DBUG_ENTER("my_create");
|
|
DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d",
|
|
FileName, CreateFlags, access_flags, MyFlags));
|
|
|
|
#if !defined(NO_OPEN_3)
|
|
fd = open((my_string) FileName, access_flags | O_CREAT,
|
|
CreateFlags ? CreateFlags : my_umask);
|
|
#elif defined(VMS)
|
|
fd = open((my_string) FileName, access_flags | O_CREAT, 0,
|
|
"ctx=stm","ctx=bin");
|
|
#elif defined(__WIN__)
|
|
fd= my_sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY,
|
|
SH_DENYNO, MY_S_IREAD | MY_S_IWRITE);
|
|
#else
|
|
fd = open(FileName, access_flags);
|
|
#endif
|
|
|
|
if ((MyFlags & MY_SYNC_DIR) && (fd >=0) &&
|
|
my_sync_dir_by_file(FileName, MyFlags))
|
|
{
|
|
my_close(fd, MyFlags);
|
|
fd= -1;
|
|
}
|
|
|
|
DBUG_RETURN(my_register_filename(fd, FileName, FILE_BY_CREATE,
|
|
EE_CANTCREATEFILE, MyFlags));
|
|
} /* my_create */
|