mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 16:32:18 +01:00 
			
		
		
		
	
				
					committed by
					
						 Emmanuel Fleury
						Emmanuel Fleury
					
				
			
			
				
	
			
			
			
						parent
						
							96c25ceba6
						
					
				
				
					commit
					3636bb5fe1
				
			| @@ -1626,6 +1626,7 @@ g_remove | ||||
| g_rmdir | ||||
| g_fopen | ||||
| g_freopen | ||||
| g_fsync | ||||
| g_chmod | ||||
| g_access | ||||
| g_creat | ||||
|   | ||||
| @@ -1641,6 +1641,31 @@ g_freopen (const gchar *filename, | ||||
| #endif | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * g_fsync: | ||||
|  * @fd: a file descriptor | ||||
|  * | ||||
|  * A wrapper for the POSIX fsync() function (_commit() on Windows). | ||||
|  * The fsync() function is used to synchronize a file's in-core | ||||
|  * state with that of the disk. | ||||
|  * | ||||
|  * See the C library manual for more details about fsync(). | ||||
|  * | ||||
|  * Returns: 0 on success, or -1 if an error occurred. | ||||
|  * The return value can be used exactly like the return value from fsync(). | ||||
|  * | ||||
|  * Since: 2.64 | ||||
|  */ | ||||
| gint | ||||
| g_fsync (gint fd) | ||||
| { | ||||
| #ifdef G_OS_WIN32 | ||||
|   return _commit (fd); | ||||
| #else | ||||
|   return fsync (fd); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * g_utime: | ||||
|  * @filename: (type filename): a pathname in the GLib file name encoding | ||||
|   | ||||
| @@ -76,6 +76,7 @@ typedef struct stat GStatBuf; | ||||
| #define g_remove  remove | ||||
| #define g_fopen   fopen | ||||
| #define g_freopen freopen | ||||
| #define g_fsync   fsync | ||||
| #define g_utime   utime | ||||
| #endif | ||||
|  | ||||
| @@ -158,6 +159,9 @@ FILE *g_freopen (const gchar *filename, | ||||
|                  const gchar *mode, | ||||
|                  FILE        *stream); | ||||
|  | ||||
| GLIB_AVAILABLE_IN_2_64 | ||||
| gint g_fsync    (gint fd); | ||||
|  | ||||
| struct utimbuf;			/* Don't need the real definition of struct utimbuf when just | ||||
| 				 * including this header. | ||||
| 				 */ | ||||
|   | ||||
| @@ -866,6 +866,7 @@ test_set_contents (void) | ||||
|   fd = g_file_open_tmp (NULL, &name, &error); | ||||
|   g_assert_no_error (error); | ||||
|   write (fd, "a", 1); | ||||
|   g_assert_cmpint (g_fsync (fd), ==, 0); | ||||
|   close (fd); | ||||
|  | ||||
|   ret = g_file_get_contents (name, &buf, &len, &error); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user