<commit_before>//
// Flump - Copyright 2012 Three Rings Design

package flump.export {

import flash.filesystem.File;
import flash.utils.ByteArray;

import deng.fzip.FZip;
import deng.fzip.FZipFile;

import flump.executor.Executor;
import flump.executor.Future;
import flump.executor.VisibleFuture;
import flump.xfl.ParseError;
import flump.xfl.XflLibrary;

import com.threerings.util.F;
import com.threerings.util.Log;

public class FlaLoader
{
    public function load (name :String, file :File) :Future {
        log.info("Loading fla", "path", file.nativePath, "name", name);

        const future :VisibleFuture = new VisibleFuture();
        _library = new XflLibrary(name);
        _loader.terminated.add(function (..._) :void {
            _library.finishLoading();
            future.succeed(_library);
        });

        var loadSWF :Future = _library.loadSWF(file.nativePath + ".swf");
        loadSWF.succeeded.add(function () :void {
            // Since listLibrary shuts down the executor, wait for the swf to load first
            listLibrary(file);
        });
        loadSWF.failed.add(F.adapt(_loader.shutdown));

        return future;
    }

    protected function listLibrary (file :File) :void {
        const loadZip :Future = Files.load(file, _loader);
        loadZip.succeeded.add(function (data :ByteArray) :void {
            const zip :FZip = new FZip();
            zip.loadBytes(data);

            const domFile :FZipFile = zip.getFileByName("DOMDocument.xml");
            const symbolPaths :Vector.<String> = _library.parseDocumentFile(
                domFile.content, domFile.filename);
            for each (var path :String in symbolPaths) {
                var symbolFile :FZipFile = zip.getFileByName(path);
                _library.parseLibraryFile(symbolFile.content, path);
            }
            _loader.shutdown();
        });
        loadZip.failed.add(function (error :Object) :void {
            _library.addTopLevelError(ParseError.CRIT, "Unable to read " + file.nativePath, error);
            _loader.shutdown();
        });
    }
<commit_msg>FlaLoader: load "MyFla.swf", not "MyFla.fla.swf"<commit_after>//
// Flump - Copyright 2012 Three Rings Design

package flump.export {

import flash.filesystem.File;
import flash.utils.ByteArray;

import deng.fzip.FZip;
import deng.fzip.FZipFile;

import flump.executor.Executor;
import flump.executor.Future;
import flump.executor.VisibleFuture;
import flump.xfl.ParseError;
import flump.xfl.XflLibrary;

import com.threerings.util.F;
import com.threerings.util.Log;

public class FlaLoader
{
    public function load (name :String, file :File) :Future {
        log.info("Loading fla", "path", file.nativePath, "name", name);

        const future :VisibleFuture = new VisibleFuture();
        _library = new XflLibrary(name);
        _loader.terminated.add(function (..._) :void {
            _library.finishLoading();
            future.succeed(_library);
        });

        var loadSWF :Future = _library.loadSWF(Files.replaceExtension(file, "swf"));
        loadSWF.succeeded.add(function () :void {
            // Since listLibrary shuts down the executor, wait for the swf to load first
            listLibrary(file);
        });
        loadSWF.failed.add(F.adapt(_loader.shutdown));

        return future;
    }

    protected function listLibrary (file :File) :void {
        const loadZip :Future = Files.load(file, _loader);
        loadZip.succeeded.add(function (data :ByteArray) :void {
            const zip :FZip = new FZip();
            zip.loadBytes(data);

            const domFile :FZipFile = zip.getFileByName("DOMDocument.xml");
            const symbolPaths :Vector.<String> = _library.parseDocumentFile(
                domFile.content, domFile.filename);
            for each (var path :String in symbolPaths) {
                var symbolFile :FZipFile = zip.getFileByName(path);
                _library.parseLibraryFile(symbolFile.content, path);
            }
            _loader.shutdown();
        });
        loadZip.failed.add(function (error :Object) :void {
            _library.addTopLevelError(ParseError.CRIT, "Unable to read " + file.nativePath, error);
            _loader.shutdown();
        });
    }

{'fraction_non_alphanumeric': 0.11388235294117648, 'fraction_numerical': 0.0018823529411764706, 'mean_word_length': 2.5662751677852347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '666571', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1239, 'n_words': 284}