mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 20:07:13 +02:00
InnoDB portability fix: new function os_file_set_eof()
innobase/include/os0file.h: Add os_file_set_eof() innobase/os/os0file.c: Add os_file_set_eof() innobase/srv/srv0srv.c: Replace chsize() or ftruncate() with os_file_set_eof() sql/ha_innodb.cc: Replace my_chsize() with os_file_set_eof()
This commit is contained in:
parent
7d918f213e
commit
48260e9d92
4 changed files with 27 additions and 6 deletions
|
|
@ -1031,6 +1031,23 @@ error_handling:
|
|||
return(FALSE);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
Truncates a file at its current position. */
|
||||
|
||||
ibool
|
||||
os_file_set_eof(
|
||||
/*============*/
|
||||
/* out: TRUE if success */
|
||||
FILE* file) /* in: file to be truncated */
|
||||
{
|
||||
#ifdef __WIN__
|
||||
HANDLE h = (HANDLE) _get_osfhandle(fileno(file));
|
||||
return(SetEndOfFile(h));
|
||||
#else /* __WIN__ */
|
||||
return(!ftruncate(fileno(file), ftell(file)));
|
||||
#endif /* __WIN__ */
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
Flushes the write buffers of a given file to the disk. */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue