#include <string.h> /* for strlen() */
#include <time.h> /* for ctime() */
#include <libgnome/libgnome.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomevfs/gnome-vfs-mime.h>
#ifdef LINUX
# include <linux/fs.h> /* for MAJOR() und MINOR() */
#endif /* LINUX */
int main (int argc, char **argv) {
if (!gnome_vfs_init())
{
g_error("%s: could not initialize GnomeVFS/n", argv[0]);
exit (2);
}
printf ("%s/n", gnome_vfs_get_file_mime_type (argv[1], NULL, FALSE));
gnome_vfs_shutdown();
return 0;
}
Linux下GnomeVFS文件MIME类型获取代码
此博客展示了一段代码,在Linux环境下,通过包含多个头文件,如<string.h>、<time.h>等,使用GnomeVFS库来获取文件的MIME类型。代码先初始化GnomeVFS,若失败则报错退出,之后打印文件MIME类型,最后关闭GnomeVFS。
3611

被折叠的 条评论
为什么被折叠?



