mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Skin Packager: Fixed that empty folders were not added
This commit is contained in:
parent
c78aad0474
commit
fe82e87b97
@ -379,28 +379,32 @@ unsigned __stdcall CDialogPackage::PackagerThreadProc(void* pParam)
|
||||
|
||||
bool CDialogPackage::AddFileToPackage(const WCHAR* filePath, const WCHAR* zipPath)
|
||||
{
|
||||
HANDLE file = CreateFile(filePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (file == INVALID_HANDLE_VALUE)
|
||||
std::string zipPathAscii = ConvertToAscii(zipPath);
|
||||
for (int i = 0, isize = zipPathAscii.length(); i < isize; ++i)
|
||||
{
|
||||
return false;
|
||||
if (zipPathAscii[i] == '\\')
|
||||
{
|
||||
zipPathAscii[i] = '/';
|
||||
}
|
||||
}
|
||||
|
||||
// Set zip file time
|
||||
zip_fileinfo zi = {0};
|
||||
FILETIME lastWriteTime;
|
||||
FILETIME localTime;
|
||||
GetFileTime(file, NULL, NULL, &lastWriteTime);
|
||||
FileTimeToLocalFileTime(&lastWriteTime, &localTime);
|
||||
FileTimeToDosDateTime(&localTime, ((LPWORD)&zi.dosDate) + 1, ((LPWORD)&zi.dosDate) + 0);
|
||||
|
||||
std::string zipPathAscii = ConvertToAscii(zipPath);
|
||||
int open = zipOpenNewFileInZip(m_ZipFile, zipPathAscii.c_str(), &zi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
|
||||
int open = zipOpenNewFileInZip(m_ZipFile, zipPathAscii.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
|
||||
if (open != ZIP_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
|
||||
if (filePath)
|
||||
{
|
||||
HANDLE file = CreateFile(filePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (file == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
const DWORD bufferSize = 16 * 1024;
|
||||
@ -423,6 +427,12 @@ bool CDialogPackage::AddFileToPackage(const WCHAR* filePath, const WCHAR* zipPat
|
||||
while (result);
|
||||
|
||||
CloseHandle(file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Directory entry, so nothing needs to be written.
|
||||
}
|
||||
|
||||
return zipCloseFileInZip(m_ZipFile) == ZIP_OK && result;
|
||||
}
|
||||
@ -449,6 +459,7 @@ bool CDialogPackage::AddFolderToPackage(const std::wstring& path, std::wstring b
|
||||
currentPath.pop_back(); // Remove *
|
||||
|
||||
bool result = true;
|
||||
bool filesAdded = false;
|
||||
std::list<std::wstring> folders;
|
||||
do
|
||||
{
|
||||
@ -480,6 +491,8 @@ bool CDialogPackage::AddFolderToPackage(const std::wstring& path, std::wstring b
|
||||
MessageBox(m_Window, error.c_str(), L"Rainmeter Skin Packager", MB_OK | MB_ICONERROR);
|
||||
break;
|
||||
}
|
||||
|
||||
filesAdded = true;
|
||||
}
|
||||
}
|
||||
while (FindNextFile(hFind, &fd));
|
||||
@ -487,6 +500,14 @@ bool CDialogPackage::AddFolderToPackage(const std::wstring& path, std::wstring b
|
||||
|
||||
if (result)
|
||||
{
|
||||
if (!filesAdded && folders.empty())
|
||||
{
|
||||
// Add directory entry if folder is empty.
|
||||
std::wstring zipPath = zipPrefix;
|
||||
zipPath.append(currentPath, path.length(), currentPath.length() - path.length());
|
||||
AddFileToPackage(NULL, zipPath.c_str());
|
||||
}
|
||||
|
||||
std::list<std::wstring>::const_iterator iter = folders.begin();
|
||||
for ( ; iter != folders.end(); ++iter)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user