diff options
author | Ryan Kelly <ryan@rfk.id.au> | 2013-07-16 16:21:33 +1000 |
---|---|---|
committer | Ryan Kelly <ryan@rfk.id.au> | 2013-07-16 16:21:33 +1000 |
commit | 77f2dc17b4ab45fa5419dd9fd92d43e4f00307df (patch) | |
tree | 94dbf3a12bb539e40f59cd35d445e8a327151660 | |
parent | ceac58b4cb40ab118d6c984c7cd63780e57fbb43 (diff) |
Fix JS syntax error when embedding an empty file.
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | tools/file_packager.py | 21 |
2 files changed, 13 insertions, 9 deletions
@@ -88,3 +88,4 @@ a license to everyone to use it as detailed in LICENSE.) * Joseph Gentle <me@josephg.com> * Douglas T. Crosher <dtc-moz@scieneer.com> (copyright owned by Mozilla Founcation) * Soeren Balko <soeren.balko@gmail.com> +* Ryan Kelly (ryan@rfk.id.au) diff --git a/tools/file_packager.py b/tools/file_packager.py index cc030f59..fb7e8a55 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -330,15 +330,18 @@ for file_ in data_files: if file_['mode'] == 'embed': # Embed data = map(ord, open(file_['srcpath'], 'rb').read()) - str_data = '' - chunk_size = 10240 - while len(data) > 0: - chunk = data[:chunk_size] - data = data[chunk_size:] - if not str_data: - str_data = str(chunk) - else: - str_data += '.concat(' + str(chunk) + ')' + if not data: + str_data = '[]' + else: + str_data = '' + chunk_size = 10240 + while len(data) > 0: + chunk = data[:chunk_size] + data = data[chunk_size:] + if not str_data: + str_data = str(chunk) + else: + str_data += '.concat(' + str(chunk) + ')' code += '''Module['FS_createDataFile']('/%s', '%s', %s, true, true);\n''' % (os.path.dirname(filename), os.path.basename(filename), str_data) elif file_['mode'] == 'preload': # Preload |