How gvdb_table_is_valid works on glib/dconf



Hi Ryan/All,
I can not understand while gvdb_table_is_valid can check the on-disk
gvdb table is valid. Then i wrote a simple sample to verify it.

"""
#include <glib.h>
#include <glib/gstdio.h>

int main()
{
	GError *err = NULL;
	gchar *data = NULL;

	system("echo 'Hello' >/tmp/mapped.txt");

	GMappedFile* mapped = g_mapped_file_new("/tmp/mapped.txt", TRUE, &err);
	data = g_mapped_file_get_contents(mapped);

	g_print("The mapped value is %d\n", !!*data);
	g_print("%s", data);

	system("echo 'World' >>/tmp/mapped.txt");

	g_print("The mapped value is %d\n", !!*data);
	g_print("%s", data);

	system("cp -f /etc/issue /tmp/mapped.txt");
	g_print("The mapped value is %d\n", !!*data);
	g_print("%s", data);

	g_mapped_file_free (mapped);
}
"""

Then I run the test program, !!*data will always output 1. Here's the
output. 

"""
The mapped value is 1
Hello
The mapped value is 1
Hello
World
The mapped value is 1

This is \n.\O (\s \m \r) \t
"""

Best regards,
Joshua




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]