Skip to content

Commit

Permalink
Better error handling; warn when no DoABC tags found
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow committed Sep 3, 2010
1 parent 54349c3 commit b691796
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions abcexport.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,35 @@ module abcexport;
import std.file;
import std.path;
import std.string;
import std.stdio;
import swffile;

void main(string[] args)
{
if (args.length == 1)
throw new Exception("No file specified");
foreach (arg; args[1..$])
{
scope swf = SWFFile.read(cast(ubyte[])read(arg));
uint count;
foreach (ref tag; swf.tags)
if ((tag.type == TagType.DoABC || tag.type == TagType.DoABC2))
{
ubyte[] abc;
if (tag.type == TagType.DoABC)
abc = tag.data;
else
try
{
scope swf = SWFFile.read(cast(ubyte[])read(arg));
uint count = 0;
foreach (ref tag; swf.tags)
if ((tag.type == TagType.DoABC || tag.type == TagType.DoABC2))
{
auto p = tag.data.ptr+4; // skip flags
while (*p++) {} // skip name
abc = tag.data[p-tag.data.ptr..$];
ubyte[] abc;
if (tag.type == TagType.DoABC)
abc = tag.data;
else
{
auto p = tag.data.ptr+4; // skip flags
while (*p++) {} // skip name
abc = tag.data[p-tag.data.ptr..$];
}
write(getName(arg) ~ .toString(count++) ~ ".abc", abc);
}
write(getName(arg) ~ .toString(count++) ~ ".abc", abc);
}
}
if (count == 0)
throw new Exception("No DoABC tags found");
}
catch (Object o)
writefln("Error while processing %s: %s", arg, o);
}

0 comments on commit b691796

Please sign in to comment.