Index: plugins/search/search-replace.c
===================================================================
--- plugins/search/search-replace.c	(Revision 4477)
+++ plugins/search/search-replace.c	(Arbeitskopie)
@@ -709,13 +709,39 @@
 static void
 save_not_opened_files(FileBuffer *fb)
 {
-	FILE *fp;
+	GFile *file;
+	GOutputStream *os;
+	gsize written;
+	gsize size;
+	gchar *buffer;
 
-	fp = fopen(fb->path, "wb");	
-	if (!fp)
-			return;
-	fwrite(fb->buf, fb->len, 1, fp);
-	fclose(fp);
+	file = g_file_new_for_uri (fb->uri);
+	os = G_OUTPUT_STREAM (g_file_replace (file, 
+			NULL,
+			FALSE,
+			G_FILE_CREATE_NONE,
+			NULL,
+			NULL));
+	if (os == NULL)
+	{
+		g_object_unref (file);
+		return;
+	}
+
+	buffer = fb->buf;
+	size = fb->len;
+	do
+	{
+		written = g_output_stream_write (os, 
+				buffer, size, NULL, NULL);
+		
+		size -= written;
+		buffer += size;
+	}
+	while (written != -1 && size > 0);
+	g_output_stream_close(os, NULL, NULL);
+	g_object_unref (os);
+	g_object_unref (file);
 }
 
 static gboolean
Index: plugins/search/search-replace_backend.c
===================================================================
--- plugins/search/search-replace_backend.c	(Revision 4477)
+++ plugins/search/search-replace_backend.c	(Arbeitskopie)
@@ -195,37 +195,73 @@
 	}
 	else
 	{
-		struct stat s;
+		GFileInfo *fi;
+		guint64 size;
 
-		if ((0 == stat(fb->path, &s)) && (S_ISREG(s.st_mode)))
+		file = g_file_new_for_path (fb->path);
+		fi = g_file_query_info (file,
+				G_FILE_ATTRIBUTE_STANDARD_SIZE ","
+				G_FILE_ATTRIBUTE_STANDARD_TYPE,
+				G_FILE_QUERY_INFO_NONE,
+				NULL, NULL);
+		if (fi != NULL && g_file_info_get_file_type(fi) == G_FILE_TYPE_REGULAR)
 		{
-			if ((fb->len = s.st_size) < 0) return NULL;
-			fb->buf = g_new(char, s.st_size + 1);
+			size = g_file_info_get_attribute_uint64(fi, G_FILE_ATTRIBUTE_STANDARD_SIZE);
+			g_object_unref (fi);
+			fi = NULL;
+
+			if ((fb->len = size) < 0) return NULL;
+			fb->buf = g_new(char, size + 1);
 			{
-				int total_bytes = 0, bytes_read, fd;
-				if (0 > (fd = open(fb->path, O_RDONLY)))
+				int total_bytes = 0, bytes_read;
+				GInputStream *is;
+				GError* error = NULL;
+
+				is = G_INPUT_STREAM (g_file_read (file, NULL, &error));
+				if (NULL == is)
 				{
-					perror(fb->path);
-					file_buffer_free(fb);
+					DEBUG_PRINT("Error opening file: %s", error->message);
+					g_error_free (error);
+					file_buffer_free (fb);
+					g_object_unref (file);
 					return NULL;
 				}
-				while (total_bytes < s.st_size)
+
+				while (total_bytes < size)
 				{
-					if (0 > (bytes_read = read(fd, fb->buf + total_bytes
-					  , s.st_size - total_bytes)))
+					bytes_read = g_input_stream_read (is,
+							fb->buf + total_bytes,
+							size - total_bytes,
+							NULL,
+							&error);
+					if (bytes_read == -1)
 					{
-						perror(fb->path);
-						close(fd);
-						file_buffer_free(fb);
+						DEBUG_PRINT("Error reading from file: %s", error->message);
+						g_error_free (error);
+						file_buffer_free (fb);
+						g_input_stream_close (is, NULL, NULL);
+						g_object_unref (is);
+						g_object_unref (file);
 						return NULL;
 					}
 					total_bytes += bytes_read;
 				}
-				close(fd);
+
+				g_input_stream_close (is, NULL, NULL);
+				g_object_unref (is);
+				g_object_unref (file);
 				fb->buf[fb->len] = '\0';
 			}
 		}
+		else
+		{
+			if (NULL != fi)
+			{
+				g_object_unref (fi);
+			}
+		}
 	}
+
 	if (!g_utf8_validate (fb->buf, MIN(MAX_VALIDATE, fb->len), NULL))
 	{
 		const AnjutaEncoding *encoding_used = NULL;
Index: ChangeLog
===================================================================
--- ChangeLog	(Revision 4477)
+++ ChangeLog	(Arbeitskopie)
@@ -1,3 +1,10 @@
+2008-12-23  Jens Georg  <mail@jensge.org>
+
+	* plugins/search/search-replace_backend.c: 
+	* plugins/search/search-replace.c:
+
+	remove usage of std i/o
+
 2008-12-22  Johannes Schmid  <jhs@gnome.org>
 
 	* plugins/document-manager/anjuta-bookmarks.c (on_title_edited),
