fix extract issues

This commit is contained in:
David Rose 2009-10-03 00:59:56 +00:00
parent a257cbbfba
commit e816ad0599
4 changed files with 24 additions and 24 deletions

View File

@ -44,7 +44,7 @@ FileSpec::
FileSpec() {
_size = 0;
_timestamp = 0;
memset(_hash, 0, sizeof(_hash));
memset(_hash, 0, hash_size);
_got_hash = false;
_actual_file = NULL;
}
@ -61,7 +61,7 @@ FileSpec(const FileSpec &copy) :
_timestamp(copy._timestamp),
_got_hash(copy._got_hash)
{
memcpy(_hash, copy._hash, sizeof(_hash));
memcpy(_hash, copy._hash, hash_size);
_actual_file = NULL;
}
@ -74,8 +74,8 @@ void FileSpec::
operator = (const FileSpec &copy) {
_filename = copy._filename;
_size = copy._size;
_timestamp = copy._size;
memcpy(_hash, copy._hash, sizeof(_hash));
_timestamp = copy._timestamp;
memcpy(_hash, copy._hash, hash_size);
_got_hash = copy._got_hash;
}
@ -260,7 +260,7 @@ check_hash(const string &pathname) const {
////////////////////////////////////////////////////////////////////
bool FileSpec::
read_hash(const string &pathname) {
memset(_hash, 0, sizeof(_hash));
memset(_hash, 0, hash_size);
ifstream stream(pathname.c_str(), ios::in | ios::binary);
if (!stream) {

View File

@ -19,16 +19,8 @@
#include <time.h>
#ifdef _WIN32
#include <sys/utime.h>
#include <direct.h>
#include <io.h>
#define stat _stat
#define utime _utime
#define utimbuf _utimbuf
#else
#include <utime.h>
#endif
// This sequence of bytes begins each Multifile to identify it as a
@ -103,7 +95,8 @@ extract_all(const string &to_dir, P3DPackage *package,
Subfiles::iterator si;
for (si = _subfiles.begin(); si != _subfiles.end(); ++si) {
const Subfile &s = (*si);
if (package != NULL && !package->is_extractable(s._filename)) {
FileSpec file;
if (package != NULL && !package->is_extractable(file, s._filename)) {
continue;
}
@ -121,15 +114,16 @@ extract_all(const string &to_dir, P3DPackage *package,
if (!extract_subfile(out, s)) {
return false;
}
// Set the timestamp according to the multifile.
out.close();
utimbuf utb;
utb.actime = time(NULL);
utb.modtime = s._timestamp;
utime(output_pathname.c_str(), &utb);
// Be sure to execute permissions on the file, in case it's a
// Check that the file was extracted correctly (and also set the
// correct timestamp).
if (!file.full_verify(to_dir)) {
nout << "After extracting, " << s._filename << " is still incorrect.\n";
return false;
}
// Be sure to set execute permissions on the file, in case it's a
// program or something.
chmod(output_pathname.c_str(), 0555);

View File

@ -810,6 +810,10 @@ build_install_plans(TiXmlDocument *doc) {
(this, new_file, source_file, target_file);
plan.push_back(step);
}
// Unpack the uncompressed archive.
step = new InstallStepUnpackArchive(this, _unpack_size);
plan.push_back(step);
}
}
}
@ -1052,13 +1056,15 @@ start_download(P3DPackage::DownloadType dtype, const string &urlbase,
// Function: P3DPackage::is_extractable
// Access: Private
// Description: Returns true if the name file is on the extract list,
// false otherwise.
// false otherwise. If true, fills in the FileSpec with
// the file's information.
////////////////////////////////////////////////////////////////////
bool P3DPackage::
is_extractable(const string &filename) const {
is_extractable(FileSpec &file, const string &filename) const {
Extracts::const_iterator ei;
for (ei = _extracts.begin(); ei != _extracts.end(); ++ei) {
if ((*ei).get_filename() == filename) {
file = (*ei);
return true;
}
}

View File

@ -207,7 +207,7 @@ private:
Download *start_download(DownloadType dtype, const string &urlbase,
const string &pathname, const FileSpec &file_spec);
bool is_extractable(const string &filename) const;
bool is_extractable(FileSpec &file, const string &filename) const;
private:
P3DHost *_host;