From 0c123b6bce0ac76af481348bf80541ff54fc223a Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 16 Jun 2009 20:02:03 +0000 Subject: [PATCH] build on win32 --- direct/src/plugin/make_package.py | 14 +++++++++++--- direct/src/plugin/p3dPackage.cxx | 32 ++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/direct/src/plugin/make_package.py b/direct/src/plugin/make_package.py index 5e35bcf1e0..c97033990c 100755 --- a/direct/src/plugin/make_package.py +++ b/direct/src/plugin/make_package.py @@ -11,6 +11,12 @@ make_package.py [opts] Options: + -s source_dir + + Specify the source directory. This is the root directory that + contains the package contents. The default is the current + directory. + -d stage_dir Specify the staging directory. This is a temporary directory on @@ -91,7 +97,7 @@ class PackageMaker: print "\ncompressing" source = open(uncompressedArchivePathname.toOsSpecific(), 'rb') - target = open(compressedArchivePathname.toOsSpecific(), 'w') + target = open(compressedArchivePathname.toOsSpecific(), 'wb') z = zlib.compressobj(9) data = source.read(4096) while data: @@ -152,12 +158,14 @@ class PackageMaker: self.archive.addSubfile(file.filename, file.pathname, 0) def makePackage(args): - opts, args = getopt.getopt(args, 'd:p:v:h') + opts, args = getopt.getopt(args, 's:d:p:v:h') pm = PackageMaker() pm.startDir = Filename('.') for option, value in opts: - if option == '-d': + if option == '-s': + pm.startDir = Filename.fromOsSpecific(value) + elif option == '-d': pm.stageDir = Filename.fromOsSpecific(value) elif option == '-p': pm.packageName = value diff --git a/direct/src/plugin/p3dPackage.cxx b/direct/src/plugin/p3dPackage.cxx index 2a4b5a516f..73bc6be8bf 100755 --- a/direct/src/plugin/p3dPackage.cxx +++ b/direct/src/plugin/p3dPackage.cxx @@ -25,13 +25,17 @@ #include #include -#include #ifdef _WIN32 +#include #include #define stat _stat #define utime _utime #define utimbuf _utimbuf + +#else +#include + #endif //////////////////////////////////////////////////////////////////// @@ -314,29 +318,38 @@ uncompress_archive() { report_done(false); return; } + + static const int decompress_buffer_size = 1024; + char decompress_buffer[decompress_buffer_size]; + static const int write_buffer_size = 1024; + char write_buffer[write_buffer_size]; z_stream z; z.next_in = Z_NULL; z.avail_in = 0; + z.next_out = Z_NULL; + z.avail_out = 0; z.zalloc = Z_NULL; z.zfree = Z_NULL; z.opaque = Z_NULL; z.msg = (char *)"no error message"; + bool eof = false; + int flush = 0; + + source.read(decompress_buffer, decompress_buffer_size); + size_t read_count = source.gcount(); + eof = (read_count == 0 || source.eof() || source.fail()); + + z.next_in = (Bytef *)decompress_buffer; + z.avail_in = read_count; + int result = inflateInit(&z); if (result < 0) { cerr << z.msg << "\n"; report_done(false); return; } - - static const int decompress_buffer_size = 1024; - char decompress_buffer[decompress_buffer_size]; - static const int write_buffer_size = 1024; - char write_buffer[write_buffer_size]; - - bool eof = false; - int flush = 0; while (true) { if (z.avail_in == 0 && !eof) { @@ -656,6 +669,7 @@ quick_verify(const string &package_dir) const { if (st.st_mtime == _timestamp) { // If the size is right and the timestamp is right, the file passes. + cerr << "file ok: " << _filename << "\n"; return true; }