summaryrefslogtreecommitdiff
path: root/innobase/os
diff options
context:
space:
mode:
authorunknown <marko@hundin.mysql.fi>2004-05-05 15:54:28 +0300
committerunknown <marko@hundin.mysql.fi>2004-05-05 15:54:28 +0300
commit48260e9d92111b40d95854e15233205a87d95da6 (patch)
treed39c68b7ae22c2cf5072e992e03afcf12836d64b /innobase/os
parent7d918f213e64df4af4b00d0798fadf9ed1a872fb (diff)
downloadmariadb-git-48260e9d92111b40d95854e15233205a87d95da6.tar.gz
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()
Diffstat (limited to 'innobase/os')
-rw-r--r--innobase/os/os0file.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 904ddf13c8f..833703e38dd 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -1032,6 +1032,23 @@ error_handling:
}
/***************************************************************************
+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. */
ibool