我有以下字符串:"/local/usr/bin/conf.xml"
。
我想将"conf.xml"
替换为例如"new_conf.xml"
以便我获得"/local/usr/bin/new_conf.xml"
知道如何使用gobject吗?
谢谢!
答案 0 :(得分:0)
使用GFile
进行路径操作:
GFile *conf = g_file_new_for_path ("/local/usr/bin/conf.xml");
GFile *parent = g_file_get_parent (conf);
GFile *new_conf = g_file_get_child (parent, "new_conf.xml");
g_object_unref (conf);
g_object_unref (parent);