Commit e82409af authored by Bastien Nocera's avatar Bastien Nocera
Browse files

2008-07-19 Bastien Nocera <hadess@hadess.net>

	* Makefile.am: Fail if the tree test failed
	* freedesktop.org.xml.in: Move some types from nautilus,
	not fully implemented yet
	* test-tree-magic.c (handle_one_line), (type_to_path),
	(print_matchlet), (main): Add some debug functionality
	* tests/tree-list: Add a test for VCDs
parent 1bac8224
2008-07-19 Bastien Nocera <hadess@hadess.net>
* Makefile.am: Fail if the tree test failed
* freedesktop.org.xml.in: Move some types from nautilus,
not fully implemented yet
* test-tree-magic.c (handle_one_line), (type_to_path),
(print_matchlet), (main): Add some debug functionality
* tests/tree-list: Add a test for VCDs
2008-07-18 Bastien Nocera <hadess@hadess.net>
* .cvsignore: upd
......
......@@ -79,7 +79,7 @@ check:
cp -a $(top_builddir)/freedesktop.org.xml $(top_builddir)/temp-mime-dir/mime/packages/ ; \
XDG_DATA_DIRS="$(top_builddir)/temp-mime-dir/" $(top_builddir)/update-mime-database "$(top_builddir)/temp-mime-dir/mime/" ; \
XDG_DATA_DIRS="$(top_builddir)/temp-mime-dir/" ../xdgmime/src/test-mime-data -v tests/list || (XDG_DATA_DIRS="$(top_builddir)/temp-mime-dir/" ../xdgmime/src/test-mime-data -v -v tests/list ; exit 1); \
XDG_DATA_DIRS="$(top_builddir)/temp-mime-dir/" $(top_builddir)/test-tree-magic tests/tree-list; \
XDG_DATA_DIRS="$(top_builddir)/temp-mime-dir/" $(top_builddir)/test-tree-magic tests/tree-list || exit 1; \
rm -rf "$(top_builddir)/temp-mime-dir/" ; \
fi
@if `grep comment $(srcdir)/freedesktop.org.xml.in | grep -v _comment | grep -q -v '<!'` ; then \
......
......@@ -4776,10 +4776,84 @@ command to generate the output files.
<!-- Tree content-types -->
<mime-type type="x-content/image-dcf">
<!-- http://en.wikipedia.org/wiki/Design_rule_for_Camera_File_system -->
<_comment>Digital Photos</_comment>
<treemagic priority="75">
<treematch path="dcim" type="directory" non-empty="true"/>
</treemagic>
</mime-type>
<mime-type type="x-content/video-vcd">
<!-- http://en.wikipedia.org/wiki/Video_CD
http://www.herongyang.com/CD-DVD/VCD-Movie-File-Directory-Structure.html -->
<_comment>Video CD</_comment>
<treemagic priority="75">
<treematch path="mpegav/AVSEQ01.DAT" type="file" />
</treemagic>
</mime-type>
<mime-type type="x-content/video-svcd">
<!-- http://en.wikipedia.org/wiki/Super_Video_CD -->
<_comment>Super Video CD</_comment>
</mime-type>
<mime-type type="x-content/video-dvd">
<!-- http://en.wikipedia.org/wiki/DVD-Video -->
<_comment>DVD Video</_comment>
</mime-type>
<mime-type type="x-content/audio-cdda">
<!-- http://en.wikipedia.org/wiki/Red_Book_(audio_CD_standard) -->
<_comment>Compact Disc Audio</_comment>
</mime-type>
<mime-type type="x-content/blank-cd">
<!-- http://en.wikipedia.org/wiki/Compact_Disc -->
<_comment>Blank CD Disc</_comment>
</mime-type>
<mime-type type="x-content/blank-dvd">
<!-- http://en.wikipedia.org/wiki/DVD -->
<_comment>Blank DVD Disc</_comment>
</mime-type>
<mime-type type="x-content/blank-bd">
<!-- http://en.wikipedia.org/wiki/Blu-ray_Disc -->
<_comment>Blank Blu-Ray Disc</_comment>
</mime-type>
<mime-type type="x-content/blank-hddvd">
<!-- http://en.wikipedia.org/wiki/HD_DVD -->
<_comment>Blank HD DVD Disc</_comment>
</mime-type>
<mime-type type="x-content/audio-dvd">
<!-- http://en.wikipedia.org/wiki/DVD-Audio -->
<_comment>DVD Audio</_comment>
</mime-type>
<mime-type type="x-content/video-bluray">
<!-- http://en.wikipedia.org/wiki/Blu-ray_Disc -->
<_comment>Blu-Ray Video</_comment>
</mime-type>
<mime-type type="x-content/video-hddvd">
<!-- http://en.wikipedia.org/wiki/HD_DVD -->
<_comment>HD DVD Video</_comment>
</mime-type>
<mime-type type="x-content/image-picturecd">
<!-- http://en.wikipedia.org/wiki/Picture_CD -->
<_comment>Picture CD</_comment>
</mime-type>
<mime-type type="x-content/audio-player">
<!-- see fd.o hal spec -->
<_comment>Portable Audio Player</_comment>
</mime-type>
<mime-type type="x-content/software">
<!-- http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html -->
<_comment>Software</_comment>
</mime-type>
</mime-info>
......@@ -556,6 +556,7 @@ handle_one_line (const char *line)
if (supposed_to_fail == FALSE) {
g_warning ("Tree %s didn't match %s (found nothing)",
filename, items[1]);
retval = FALSE;
} else {
g_message ("Tree %s failed to match %s (expected)",
filename, items[1]);
......@@ -599,6 +600,34 @@ bail:
return retval;
}
static const char *
type_to_path (GFileType type)
{
switch (type) {
case G_FILE_TYPE_REGULAR:
return "Regular";
case G_FILE_TYPE_DIRECTORY:
return "Directory";
case G_FILE_TYPE_SYMBOLIC_LINK:
return "Symbolic link";
default:
return "Unknown";
}
}
static void
print_matchlet (TreeMatchlet *matchlet, guint depth)
{
GList *l;
guint i;
for (i = depth + 1; i != 0; i--)
g_print ("\t");
g_print ("%s (type=%s)\n", matchlet->path, type_to_path (matchlet->type));
for (l = matchlet->matches ; l != NULL; l = l->next)
print_matchlet (l->data, depth + 1);
}
int main (int argc, char **argv)
{
GError *error = NULL;
......@@ -620,6 +649,22 @@ int main (int argc, char **argv)
return 1;
}
if (strcmp (argv[1], "-d") == 0) {
GList *l;
tree_magic_init ();
for (l = tree_matches ; l != NULL; l = l->next) {
GList *k;
TreeMatch *match = (TreeMatch *) l->data;
g_print ("Type: %s\n", match->contenttype);
for (k = match->matches ; k != NULL; k = k->next) {
TreeMatchlet *matchlet = (TreeMatchlet *) k->data;
print_matchlet (matchlet, 0);
}
}
return 0;
}
if (g_file_get_contents (argv[1], &content, NULL, &error) == FALSE) {
g_warning ("Failed to load %s: %s", argv[1], error->message);
return 1;
......
# Supposed to work
tests/image-dcf x-content/image-dcf
tests/video-vcd x-content/video-vcd
# Supposed to fail
x tests/ x-content/image-dcf
x tests x-content/image-dcf
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment