mirror of
https://github.com/pocoproject/poco.git
synced 2025-05-31 00:04:36 +02:00
fixed SF# 2583934: Zip: No Unix permissions set
This commit is contained in:
parent
717dd9cf45
commit
12c1ae5823
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ZipFileInfo.h
|
// ZipFileInfo.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Zip/include/Poco/Zip/ZipFileInfo.h#3 $
|
// $Id: //poco/Main/Zip/include/Poco/Zip/ZipFileInfo.h#8 $
|
||||||
//
|
//
|
||||||
// Library: Zip
|
// Library: Zip
|
||||||
// Package: Zip
|
// Package: Zip
|
||||||
@ -139,6 +139,8 @@ private:
|
|||||||
|
|
||||||
void setFileName(const std::string& str);
|
void setFileName(const std::string& str);
|
||||||
|
|
||||||
|
void setExternalFileAttributes(Poco::UInt32 attrs);
|
||||||
|
|
||||||
void parse(std::istream& in, bool assumeHeaderRead);
|
void parse(std::istream& in, bool assumeHeaderRead);
|
||||||
|
|
||||||
void parseDateTime();
|
void parseDateTime();
|
||||||
@ -157,6 +159,8 @@ private:
|
|||||||
|
|
||||||
Poco::UInt32 getExternalFileAttributes() const;
|
Poco::UInt32 getExternalFileAttributes() const;
|
||||||
|
|
||||||
|
void setUnixAttributes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -196,6 +200,12 @@ private:
|
|||||||
FULLHEADER_SIZE = 46
|
FULLHEADER_SIZE = 46
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
DEFAULT_UNIX_FILE_MODE = 0640,
|
||||||
|
DEFAULT_UNIX_DIR_MODE = 0755
|
||||||
|
};
|
||||||
|
|
||||||
char _rawInfo[FULLHEADER_SIZE];
|
char _rawInfo[FULLHEADER_SIZE];
|
||||||
Poco::UInt32 _crc32;
|
Poco::UInt32 _crc32;
|
||||||
Poco::UInt32 _compressedSize;
|
Poco::UInt32 _compressedSize;
|
||||||
@ -462,6 +472,12 @@ inline void ZipFileInfo::setFileName(const std::string& str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void ZipFileInfo::setExternalFileAttributes(Poco::UInt32 attrs)
|
||||||
|
{
|
||||||
|
ZipUtil::set32BitValue(attrs, _rawInfo, EXTERNALFILE_ATTR_POS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Zip
|
} } // namespace Poco::Zip
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Compress.cpp
|
// Compress.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Zip/src/Compress.cpp#4 $
|
// $Id: //poco/Main/Zip/src/Compress.cpp#8 $
|
||||||
//
|
//
|
||||||
// Library: Zip
|
// Library: Zip
|
||||||
// Package: Zip
|
// Package: Zip
|
||||||
@ -180,7 +180,6 @@ void Compress::addFile(const Poco::Path& file, const Poco::Path& fileName, ZipCo
|
|||||||
cm = ZipCommon::CM_STORE;
|
cm = ZipCommon::CM_STORE;
|
||||||
cl = ZipCommon::CL_NORMAL;
|
cl = ZipCommon::CL_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ifstream in(file.toString().c_str(), std::ios::binary);
|
std::ifstream in(file.toString().c_str(), std::ios::binary);
|
||||||
if (!in.good())
|
if (!in.good())
|
||||||
throw ZipException("Invalid input stream for " + aFile.path());
|
throw ZipException("Invalid input stream for " + aFile.path());
|
||||||
@ -189,6 +188,7 @@ void Compress::addFile(const Poco::Path& file, const Poco::Path& fileName, ZipCo
|
|||||||
Poco::File aParent(file.parent());
|
Poco::File aParent(file.parent());
|
||||||
addDirectory(fileName.parent(), aParent.getLastModified());
|
addDirectory(fileName.parent(), aParent.getLastModified());
|
||||||
}
|
}
|
||||||
|
|
||||||
addFile(in, aFile.getLastModified(), fileName, cm, cl);
|
addFile(in, aFile.getLastModified(), fileName, cm, cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ZipFileInfo.cpp
|
// ZipFileInfo.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Zip/src/ZipFileInfo.cpp#4 $
|
// $Id: //poco/Main/Zip/src/ZipFileInfo.cpp#9 $
|
||||||
//
|
//
|
||||||
// Library: Zip
|
// Library: Zip
|
||||||
// Package: Zip
|
// Package: Zip
|
||||||
@ -69,6 +69,9 @@ ZipFileInfo::ZipFileInfo(const ZipLocalFileHeader& header):
|
|||||||
setLastModifiedAt(header.lastModifiedAt());
|
setLastModifiedAt(header.lastModifiedAt());
|
||||||
setEncryption(false);
|
setEncryption(false);
|
||||||
setFileName(header.getFileName());
|
setFileName(header.getFileName());
|
||||||
|
|
||||||
|
if (getHostSystem() == ZipCommon::HS_UNIX)
|
||||||
|
setUnixAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -140,4 +143,17 @@ std::string ZipFileInfo::createHeader() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ZipFileInfo::setUnixAttributes()
|
||||||
|
{
|
||||||
|
bool isDir = isDirectory();
|
||||||
|
int mode;
|
||||||
|
if (isDir)
|
||||||
|
mode = DEFAULT_UNIX_DIR_MODE;
|
||||||
|
else
|
||||||
|
mode = DEFAULT_UNIX_FILE_MODE;
|
||||||
|
Poco::UInt32 attrs = (mode << 16) | (isDir ? 0x10 : 0);
|
||||||
|
setExternalFileAttributes(attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Zip
|
} } // namespace Poco::Zip
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ZipStream.cpp
|
// ZipStream.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Zip/src/ZipStream.cpp#4 $
|
// $Id: //poco/Main/Zip/src/ZipStream.cpp#14 $
|
||||||
//
|
//
|
||||||
// Library: Zip
|
// Library: Zip
|
||||||
// Package: Zip
|
// Package: Zip
|
||||||
|
Loading…
x
Reference in New Issue
Block a user