howto use g_file_load_contents

  GFile *file;
  gchar *contents;
  gchar **lines;
  int i;

  file = g_file_new_for_path ("test_file");
  if (!g_file_load_contents (file, NULL, &contents, NULL, NULL, NULL))
    return;
  lines = g_strsplit (contents, "\n", 0);
  g_free (contents);

  for (i = 0; lines[i] != NULL; i++) {
    g_message (lines[i]);
  }
  g_strfreev (lines);

猜你喜欢

转载自socol.iteye.com/blog/1152686