mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-24 18:08:54 +02:00
g_file_set_contents(): use posix_fallocate()
Extents-based filesystems like knowing in advance how much data will be written to a file in order to prevent fragmentation. If we have it, use posix_fallocate() before writing data in g_file_set_contents(). https://bugzilla.gnome.org/show_bug.cgi?id=701560
This commit is contained in:
@@ -1059,6 +1059,13 @@ write_to_temp_file (const gchar *contents,
|
||||
if (length > 0)
|
||||
{
|
||||
gsize n_written;
|
||||
|
||||
#ifdef HAVE_POSIX_FALLOCATE
|
||||
/* We do this on a 'best effort' basis... It may not be supported
|
||||
* on the underlying filesystem.
|
||||
*/
|
||||
(void) posix_fallocate (fd, 0, length);
|
||||
#endif
|
||||
|
||||
errno = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user