mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-22 01:34:21 +00:00
Added support for uncompressing symbolic links in zip files
This commit is contained in:
parent
0c18f1cab7
commit
7bcd6a5ecd
2 changed files with 16 additions and 0 deletions
|
|
@ -46,6 +46,10 @@ struct ZipFile::ZipEntryHolder
|
|||
entry.uncompressedSize = (int64) readUnalignedLittleEndianInt (buffer + 24);
|
||||
streamOffset = (int64) readUnalignedLittleEndianInt (buffer + 42);
|
||||
|
||||
auto externalFileAttributes = (int32) readUnalignedLittleEndianInt (buffer + 38);
|
||||
auto fileType = (externalFileAttributes >> 28) & 0xf;
|
||||
|
||||
entry.isSymbolicLink = (fileType == 0xA);
|
||||
entry.filename = String::fromUTF8 (buffer + 46, fileNameLen);
|
||||
}
|
||||
|
||||
|
|
@ -430,6 +434,15 @@ Result ZipFile::uncompressEntry (int index, const File& targetDirectory, bool sh
|
|||
if (! targetFile.getParentDirectory().createDirectory())
|
||||
return Result::fail ("Failed to create target folder: " + targetFile.getParentDirectory().getFullPathName());
|
||||
|
||||
if (zei->entry.isSymbolicLink)
|
||||
{
|
||||
String relativePath (in->readEntireStreamAsString());
|
||||
auto originalFilePath = targetFile.getParentDirectory().getChildFile (relativePath);
|
||||
|
||||
if (! originalFilePath.createSymbolicLink (targetFile, true))
|
||||
return Result::fail ("Failed to create symbolic link: " + targetFile.getFullPathName());
|
||||
}
|
||||
else
|
||||
{
|
||||
FileOutputStream out (targetFile);
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,9 @@ public:
|
|||
|
||||
/** The last time the file was modified. */
|
||||
Time fileTime;
|
||||
|
||||
/** True if the zip entry is a symbolic link. */
|
||||
bool isSymbolicLink;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue