1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-23 01:44:22 +00:00

ZipFile: made sure backslashes in paths are converted to forward slashes on unix OSes.

This commit is contained in:
jules 2013-03-08 19:16:28 +00:00
parent aacb92a33a
commit 2b8d19edaf

View file

@ -111,21 +111,21 @@ namespace
class ZipFile::ZipInputStream : public InputStream
{
public:
ZipInputStream (ZipFile& file_, ZipFile::ZipEntryHolder& zei)
: file (file_),
ZipInputStream (ZipFile& zf, ZipFile::ZipEntryHolder& zei)
: file (zf),
zipEntryHolder (zei),
pos (0),
headerSize (0),
inputStream (file_.inputStream)
inputStream (zf.inputStream)
{
if (file_.inputSource != nullptr)
if (zf.inputSource != nullptr)
{
inputStream = streamToDelete = file.inputSource->createInputStream();
}
else
{
#if JUCE_DEBUG
file_.streamCounter.numOpenStreams++;
zf.streamCounter.numOpenStreams++;
#endif
}
@ -233,9 +233,9 @@ ZipFile::ZipFile (const File& file)
init();
}
ZipFile::ZipFile (InputSource* const inputSource_)
ZipFile::ZipFile (InputSource* const source)
: inputStream (nullptr),
inputSource (inputSource_)
inputSource (source)
{
init();
}
@ -391,9 +391,15 @@ Result ZipFile::uncompressEntry (const int index,
{
const ZipEntryHolder* zei = entries.getUnchecked (index);
const File targetFile (targetDirectory.getChildFile (zei->entry.filename));
#if JUCE_WINDOWS
const String entryPath (zei->entry.filename);
#else
const String entryPath (zei->entry.filename.replaceCharacter ('\\', '/'));
#endif
if (zei->entry.filename.endsWithChar ('/'))
const File targetFile (targetDirectory.getChildFile (entryPath));
if (entryPath.endsWithChar ('/') || entryPath.endsWithChar ('\\'))
return targetFile.createDirectory(); // (entry is a directory, not a file)
ScopedPointer<InputStream> in (createStreamForEntry (index));
@ -431,15 +437,15 @@ Result ZipFile::uncompressEntry (const int index,
//=============================================================================
extern unsigned long juce_crc32 (unsigned long crc, const unsigned char* buf, unsigned len);
extern unsigned long juce_crc32 (unsigned long crc, const unsigned char*, unsigned len);
class ZipFile::Builder::Item
{
public:
Item (const File& file_, const int compressionLevel_, const String& storedPathName_)
: file (file_),
storedPathname (storedPathName_.isEmpty() ? file_.getFileName() : storedPathName_),
compressionLevel (compressionLevel_),
Item (const File& f, const int compression, const String& storedPath)
: file (f),
storedPathname (storedPath.isEmpty() ? f.getFileName() : storedPath),
compressionLevel (compression),
compressedSize (0),
headerStart (0)
{