Mercurial > audlegacy-plugins
comparison src/stdio/stdio.c @ 1935:c276e2b74646
Backed out changeset 31e9908cf91e
It has been decided that using libmagic is a bad idea due to false positives.
| author | William Pitcock <nenolod@atheme.org> |
|---|---|
| date | Mon, 01 Oct 2007 15:34:40 -0500 |
| parents | 31e9908cf91e |
| children | 2ebeb7816c5e |
comparison
equal
deleted
inserted
replaced
| 1921:31e9908cf91e | 1935:c276e2b74646 |
|---|---|
| 25 #include <sys/stat.h> | 25 #include <sys/stat.h> |
| 26 #include <sys/types.h> | 26 #include <sys/types.h> |
| 27 | 27 |
| 28 #include <string.h> | 28 #include <string.h> |
| 29 | 29 |
| 30 #include <magic.h> | |
| 31 | |
| 32 static gchar * | 30 static gchar * |
| 33 vfs_stdio_urldecode_path(const gchar * encoded_path) | 31 vfs_stdio_urldecode_path(const gchar * encoded_path) |
| 34 { | 32 { |
| 35 const gchar *cur, *ext; | 33 const gchar *cur, *ext; |
| 36 gchar *path, *tmp; | 34 gchar *path, *tmp; |
| 249 return -1; | 247 return -1; |
| 250 | 248 |
| 251 return s.st_size; | 249 return s.st_size; |
| 252 } | 250 } |
| 253 | 251 |
| 254 static magic_t mdb_handle = NULL; | |
| 255 | |
| 256 gchar * | |
| 257 stdio_vfs_metadata_impl(VFSFile *file, const gchar *field) | |
| 258 { | |
| 259 if (!g_ascii_strcasecmp(field, "content-type")) | |
| 260 { | |
| 261 gchar *decpath; | |
| 262 const gchar *out; | |
| 263 | |
| 264 if (mdb_handle == NULL) | |
| 265 mdb_handle = magic_open(MAGIC_MIME); | |
| 266 | |
| 267 decpath = vfs_stdio_urldecode_path(file->uri); | |
| 268 out = magic_file(mdb_handle, decpath); | |
| 269 | |
| 270 return g_strdup(out); | |
| 271 } | |
| 272 | |
| 273 return NULL; | |
| 274 } | |
| 275 | |
| 276 VFSConstructor file_const = { | 252 VFSConstructor file_const = { |
| 277 "file://", | 253 "file://", |
| 278 stdio_vfs_fopen_impl, | 254 stdio_vfs_fopen_impl, |
| 279 stdio_vfs_fclose_impl, | 255 stdio_vfs_fclose_impl, |
| 280 stdio_vfs_fread_impl, | 256 stdio_vfs_fread_impl, |
| 284 stdio_vfs_fseek_impl, | 260 stdio_vfs_fseek_impl, |
| 285 stdio_vfs_rewind_impl, | 261 stdio_vfs_rewind_impl, |
| 286 stdio_vfs_ftell_impl, | 262 stdio_vfs_ftell_impl, |
| 287 stdio_vfs_feof_impl, | 263 stdio_vfs_feof_impl, |
| 288 stdio_vfs_truncate_impl, | 264 stdio_vfs_truncate_impl, |
| 289 stdio_vfs_fsize_impl, | 265 stdio_vfs_fsize_impl |
| 290 stdio_vfs_metadata_impl | |
| 291 }; | 266 }; |
| 292 | 267 |
| 293 static void init(void) | 268 static void init(void) |
| 294 { | 269 { |
| 295 vfs_register_transport(&file_const); | 270 vfs_register_transport(&file_const); |
