97 sys.exit(
'Usage: %s directory output_file.cpp' % sys.argv[0])
98 directory = sys.argv[1]
100 for dirName, subdirList, fileList
in walk(directory):
101 for fname
in sorted(fileList):
102 subdir = dirName[len(directory)+1:]
if dirName.startswith(directory)
else dirName
104 files.append(File.factory(directory,subdir,fname))
105 outputFile =
open(sys.argv[2],
"w")
106 print(
"#include \"resourcemgr.h\"\n",file=outputFile)
108 f.writeContents(outputFile)
109 print(
"static Resource resourceDir[] =",file=outputFile)
110 print(
"{",file=outputFile)
112 f.writeDirEntry(outputFile)
113 print(
"};",file=outputFile)
114 print(
"static int resourceDir_len = %s;" % len(files), file=outputFile)
115 print(
"void initResources() { ResourceMgr::instance().registerResources(resourceDir,resourceDir_len); }",file=outputFile)
int open(const char *, int)
Opens a file descriptor.
def walk(top, topdown=True)