Fix for working with symlinks in tar files
This commit is contained in:
parent
739d692e72
commit
79b8d61ae9
|
@ -1801,43 +1801,43 @@ bool cmSystemTools::CreateTar(const char* outFileName,
|
||||||
}
|
}
|
||||||
// Set the name of the entry to the file name
|
// Set the name of the entry to the file name
|
||||||
archive_entry_set_pathname(entry, rp.c_str());
|
archive_entry_set_pathname(entry, rp.c_str());
|
||||||
struct stat s;
|
archive_read_disk_entry_from_file(disk, entry, -1, 0);
|
||||||
stat(fileIt->c_str(), &s);
|
|
||||||
archive_read_disk_entry_from_file(disk, entry, -1, &s);
|
|
||||||
CHECK_ARCHIVE_ERROR(res, "read disk entry:");
|
CHECK_ARCHIVE_ERROR(res, "read disk entry:");
|
||||||
|
|
||||||
// write entry header
|
// write entry header
|
||||||
res = archive_write_header(a, entry);
|
res = archive_write_header(a, entry);
|
||||||
CHECK_ARCHIVE_ERROR(res, "write header: ");
|
CHECK_ARCHIVE_ERROR(res, "write header: ");
|
||||||
|
if(archive_entry_size(entry) > 0)
|
||||||
// now copy contents of file into archive a
|
|
||||||
FILE* file = fopen(fileIt->c_str(), "rb");
|
|
||||||
if(!file)
|
|
||||||
{
|
{
|
||||||
cmSystemTools::Error("Problem with fopen(): ",
|
// now copy contents of file into archive a
|
||||||
fileIt->c_str());
|
FILE* file = fopen(fileIt->c_str(), "rb");
|
||||||
return false;
|
if(!file)
|
||||||
}
|
|
||||||
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;
|
cmSystemTools::Error("Problem with fopen(): ",
|
||||||
error << "Problem with archive_write_data\n"
|
fileIt->c_str());
|
||||||
<< "Tried to write [" << len << "] bytes.\n"
|
return false;
|
||||||
<< "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);
|
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);
|
||||||
|
}
|
||||||
|
// close the file and free the entry
|
||||||
|
fclose(file);
|
||||||
}
|
}
|
||||||
// close the file and free the entry
|
|
||||||
fclose(file);
|
|
||||||
archive_entry_free(entry);
|
archive_entry_free(entry);
|
||||||
}
|
}
|
||||||
// close the archive and finish the write
|
// close the archive and finish the write
|
||||||
|
|
Loading…
Reference in New Issue