Skip to content

Commit

Permalink
remove race in directory creation in nop_converter
Browse files Browse the repository at this point in the history
issue #8
  • Loading branch information
neogeographica committed Nov 21, 2013
1 parent fe0e67a commit ffa3574
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions expak.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def ogg_converter(orig_data, name):
import struct
import sys
import os
import errno

PAK_FILE_SIGNATURE = "PACK"
RESOURCE_NAME_LEN = 56
Expand Down Expand Up @@ -377,8 +378,12 @@ def nop_converter(orig_data, name):
"""
real_path = os.path.join(*name.split("/"))
out_dir = os.path.dirname(real_path)
if out_dir and not os.path.exists(out_dir):
os.makedirs(out_dir)
if out_dir:
try:
os.makedirs(out_dir)
except OSError, e:
if e.errno != errno.EEXIST:
raise
with open(real_path, 'wb') as outstream:
outstream.write(orig_data)
return True
Expand Down

0 comments on commit ffa3574

Please sign in to comment.