display-name: "Containers/RIFF"

file-format riff
{
	file[1]
	{
		fixed-string(4) name
		unsigned32 size
		size = size - 4
		fixed-string(4) specific-name
		name = name + specific-name
		offset: file.position

		interpret-as "riff-root"
	}
}

file-format riff-root
{
	file while (file.remaining-bytes > 4)
	{
		fixed-string(4) name
		unsigned32 size
		offset: file.position

		if (name == "LIST")
		{
			fixed-string(4) name
			size = size - 4
			offset = offset + 4
			interpret-as "riff-root"
		}

		data(size) file-data
		if ((size % 2) == 1)
		{
			unsigned8 padding-byte
		}
	}
}

file-format riff-list
{
	file while (file.remaining-bytes > 4)
	{
		fixed-string(4) name
		unsigned32 size
		offset: file.position

		data(size) file-data
		if ((size % 2) == 1)
		{
			unsigned8 padding-byte
		}

		if (name == "LIST")
		{
			interpret-as "riff-root"
		}
	}
}

if (file.name like "*.*")
{
	interpret-as "riff"
}