diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2009-11-09 00:59:01 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2009-11-09 00:59:01 (GMT) |
commit | 79b8d61ae93cb75a9f45a96ccc769ccb3807da0e (patch) | |
tree | c16fa29920faa99fc5b3bcefd910616096ecfe8f | |
parent | 739d692e722c9d1af215e978e9e202f195b60bc3 (diff) | |
download | CMake-79b8d61ae93cb75a9f45a96ccc769ccb3807da0e.zip CMake-79b8d61ae93cb75a9f45a96ccc769ccb3807da0e.tar.gz CMake-79b8d61ae93cb75a9f45a96ccc769ccb3807da0e.tar.bz2 |
Fix for working with symlinks in tar files
-rw-r--r-- | Source/cmSystemTools.cxx | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 62603d6..88f96d1 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1801,43 +1801,43 @@ bool cmSystemTools::CreateTar(const char* outFileName, } // Set the name of the entry to the file name archive_entry_set_pathname(entry, rp.c_str()); - struct stat s; - stat(fileIt->c_str(), &s); - archive_read_disk_entry_from_file(disk, entry, -1, &s); + archive_read_disk_entry_from_file(disk, entry, -1, 0); CHECK_ARCHIVE_ERROR(res, "read disk entry:"); // write entry header res = archive_write_header(a, entry); CHECK_ARCHIVE_ERROR(res, "write header: "); - - // now copy contents of file into archive a - FILE* file = fopen(fileIt->c_str(), "rb"); - if(!file) + if(archive_entry_size(entry) > 0) { - cmSystemTools::Error("Problem with fopen(): ", - fileIt->c_str()); - return false; - } - char buff[16384]; - size_t len = fread(buff, 1, sizeof(buff), file); - while (len > 0) - { - size_t wlen = archive_write_data(a, buff, len); - if(wlen != len) - { - cmOStringStream error; - error << "Problem with archive_write_data\n" - << "Tried to write [" << len << "] bytes.\n" - << "archive_write_data wrote [" << wlen << "] bytes.\n"; - cmSystemTools::Error(error.str().c_str(), - archive_error_string(a) - ); - return false; + // now copy contents of file into archive a + FILE* file = fopen(fileIt->c_str(), "rb"); + if(!file) + { + cmSystemTools::Error("Problem with fopen(): ", + fileIt->c_str()); + return false; + } + char buff[16384]; + size_t len = fread(buff, 1, sizeof(buff), file); + while (len > 0) + { + size_t wlen = archive_write_data(a, buff, len); + if(wlen != len) + { + cmOStringStream error; + error << "Problem with archive_write_data\n" + << "Tried to write [" << len << "] bytes.\n" + << "archive_write_data wrote [" << wlen << "] bytes.\n"; + cmSystemTools::Error(error.str().c_str(), + archive_error_string(a) + ); + return false; + } + len = fread(buff, 1, sizeof(buff), file); } - len = fread(buff, 1, sizeof(buff), file); + // close the file and free the entry + fclose(file); } - // close the file and free the entry - fclose(file); archive_entry_free(entry); } // close the archive and finish the write |