X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Frfxswf.c;h=93f5db5d2d287b3faa34083ed9093c271b1caa9d;hb=8d26cc0baf8f7d05e72bc7b8e5f1a6f7caa9f158;hp=de66911aba764edfcc71dbd8a816af242fec114b;hpb=f71ae3218035fa627852e76e246b2752883358af;p=swftools.git diff --git a/lib/rfxswf.c b/lib/rfxswf.c index de66911..93f5db5 100644 --- a/lib/rfxswf.c +++ b/lib/rfxswf.c @@ -1475,6 +1475,19 @@ int swf_ReadSWF2(reader_t*reader, SWF * swf) // Reads SWF to memory (malloc'ed return reader->pos; } +SWF* swf_OpenSWF(char*filename) +{ + int fi = open(filename, O_RDONLY|O_BINARY); + if(fi<0) { + fprintf(stderr, "Failed to open %s\n", filename); + return 0; + } + SWF* swf = rfx_alloc(sizeof(SWF)); + swf_ReadSWF(fi, swf); + close(fi); + return swf; +} + int swf_ReadSWF(int handle, SWF * swf) { reader_t reader; @@ -1578,7 +1591,9 @@ int swf_WriteSWF2(writer_t*writer, SWF * swf) // Writes SWF to file, return t = swf->firstTag; frameCount = 0; - len += WriteExtraTags(swf, 0); + if(swf->firstTag && !no_extra_tags) { + len += WriteExtraTags(swf, 0); + } while(t) { len += swf_WriteTag(-1,t); if(t->id == ST_DEFINESPRITE && !swf_IsFolded(t)) inSprite++; @@ -1660,7 +1675,7 @@ int swf_WriteSWF2(writer_t*writer, SWF * swf) // Writes SWF to file, return return -1; } - if(!no_extra_tags) { + if(swf->firstTag && !no_extra_tags) { WriteExtraTags(swf, writer); } t = swf->firstTag;