aboutsummaryrefslogtreecommitdiff
path: root/tools/file_packager.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-07-16 15:11:49 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-16 15:11:49 -0700
commitc9c6d2f66333cc5d4826a57cacd77c1435b16b73 (patch)
treea4c380ff82fffd848f1edbb56517b28cffef6c02 /tools/file_packager.py
parent1d8b642b43f38571739e86f82d39df7965ea9984 (diff)
parent3a2e897b45caaf2ac16634b4e1ce57ca048a6bc1 (diff)
Merge pull request #1389 from rfk/embed-empty-files
Fix JS syntax error when embedding an empty file.
Diffstat (limited to 'tools/file_packager.py')
-rw-r--r--tools/file_packager.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/file_packager.py b/tools/file_packager.py
index cc030f59..575e5957 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