mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[SHELL32][ZIPFLDR] Implement SendTo ZIP folder (#2118)
Follow-up of #2114. - s/Creater/Creator/ - Add an empty file in the SendTo folder. - Trick. CORE-16495
This commit is contained in:
parent
c35ebdfeb6
commit
f1bc04d7e6
7 changed files with 39 additions and 22 deletions
|
@ -29,7 +29,7 @@ list(APPEND SOURCE
|
|||
CEnumZipContents.cpp
|
||||
CFolderViewCB.cpp
|
||||
CSendToZip.cpp
|
||||
CZipCreater.cpp
|
||||
CZipCreator.cpp
|
||||
CZipEnumerator.hpp
|
||||
CZipExtract.cpp
|
||||
CZipFolder.hpp
|
||||
|
|
|
@ -47,12 +47,10 @@ CSendToZip::Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt,
|
|||
DWORD *pdwEffect)
|
||||
{
|
||||
m_pDataObject = pDataObj;
|
||||
*pdwEffect &= DROPEFFECT_COPY;
|
||||
|
||||
if (!pDataObj || !m_fCanDragDrop || !*pdwEffect)
|
||||
if (!pDataObj || !m_fCanDragDrop)
|
||||
{
|
||||
DPRINT1("Drop failed: %d %d %d\n",
|
||||
!pDataObj, !m_fCanDragDrop, !*pdwEffect);
|
||||
DPRINT1("Drop failed: %d %d\n", !pDataObj, !m_fCanDragDrop);
|
||||
*pdwEffect = 0;
|
||||
DragLeave();
|
||||
return E_FAIL;
|
||||
|
@ -71,19 +69,19 @@ CSendToZip::Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt,
|
|||
HDROP hDrop = reinterpret_cast<HDROP>(stg.hGlobal);
|
||||
UINT cItems = ::DragQueryFileW(hDrop, -1, NULL, 0);
|
||||
|
||||
CZipCreator *pCreater = CZipCreator::DoCreate();
|
||||
CZipCreator *pCreator = CZipCreator::DoCreate();
|
||||
|
||||
for (UINT iItem = 0; iItem < cItems; ++iItem)
|
||||
{
|
||||
WCHAR szPath[MAX_PATH];
|
||||
DragQueryFileW(hDrop, iItem, szPath, _countof(szPath));
|
||||
|
||||
pCreater->DoAddItem(szPath);
|
||||
pCreator->DoAddItem(szPath);
|
||||
}
|
||||
|
||||
::ReleaseStgMedium(&stg);
|
||||
|
||||
CZipCreator::runThread(pCreater); // pCreater is deleted in runThread
|
||||
CZipCreator::runThread(pCreator); // pCreator is deleted in runThread
|
||||
|
||||
DragLeave();
|
||||
return hr;
|
||||
|
|
|
@ -46,21 +46,22 @@ public:
|
|||
}
|
||||
STDMETHODIMP Save(LPCOLESTR pszFileName, BOOL fRemember)
|
||||
{
|
||||
return E_FAIL;
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
STDMETHODIMP SaveCompleted(LPCOLESTR pszFileName)
|
||||
{
|
||||
return E_FAIL;
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
STDMETHODIMP GetCurFile(LPOLESTR *ppszFileName)
|
||||
{
|
||||
return E_FAIL;
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
// *** IPersist methods ***
|
||||
STDMETHODIMP GetClassID(CLSID *pclsid)
|
||||
{
|
||||
return E_FAIL;
|
||||
*pclsid = CLSID_ZipFolderSendTo;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
@ -182,15 +182,15 @@ CZipCreator::~CZipCreator()
|
|||
static unsigned __stdcall
|
||||
create_zip_function(void *arg)
|
||||
{
|
||||
CZipCreator *pCreater = reinterpret_cast<CZipCreator *>(arg);
|
||||
return pCreater->m_pimpl->JustDoIt();
|
||||
CZipCreator *pCreator = reinterpret_cast<CZipCreator *>(arg);
|
||||
return pCreator->m_pimpl->JustDoIt();
|
||||
}
|
||||
|
||||
BOOL CZipCreator::runThread(CZipCreator *pCreater)
|
||||
BOOL CZipCreator::runThread(CZipCreator *pCreator)
|
||||
{
|
||||
unsigned tid = 0;
|
||||
HANDLE hThread = reinterpret_cast<HANDLE>(
|
||||
_beginthreadex(NULL, 0, create_zip_function, pCreater, 0, &tid));
|
||||
_beginthreadex(NULL, 0, create_zip_function, pCreator, 0, &tid));
|
||||
|
||||
if (hThread)
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ BOOL CZipCreator::runThread(CZipCreator *pCreater)
|
|||
CStringW strText(MAKEINTRESOURCEW(IDS_CANTSTARTTHREAD));
|
||||
MessageBoxW(NULL, strText, strTitle, MB_ICONERROR);
|
||||
|
||||
delete pCreater;
|
||||
delete pCreator;
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
* COPYRIGHT: Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
|
||||
* Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
|
||||
*/
|
||||
#ifndef CZIPCREATER_HPP_
|
||||
#define CZIPCREATER_HPP_
|
||||
#ifndef CZIPCREATOR_HPP_
|
||||
#define CZIPCREATOR_HPP_
|
||||
|
||||
struct CZipCreatorImpl;
|
||||
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
}
|
||||
|
||||
virtual void DoAddItem(LPCWSTR pszFile);
|
||||
static BOOL runThread(CZipCreator* pCreater);
|
||||
static BOOL runThread(CZipCreator* pCreator);
|
||||
|
||||
protected:
|
||||
CZipCreator();
|
|
@ -78,7 +78,7 @@ eZipConfirmResponse _CZipAskReplace(HWND hDlg, const char* FullPath);
|
|||
|
||||
#include "CZipEnumerator.hpp"
|
||||
#include "CZipFolder.hpp"
|
||||
#include "CZipCreater.hpp"
|
||||
#include "CZipCreator.hpp"
|
||||
#include "CSendToZip.hpp"
|
||||
|
||||
#endif /* ZIPFLDR_PRECOMP_H */
|
||||
|
|
|
@ -2224,6 +2224,7 @@ HRESULT DoCreateSendToFiles(LPCWSTR pszSendTo)
|
|||
WCHAR szShell32[MAX_PATH];
|
||||
HRESULT hr;
|
||||
HANDLE hFile;
|
||||
HINSTANCE hZipFldr;
|
||||
|
||||
/* create my documents */
|
||||
SHGetSpecialFolderPathW(NULL, szTarget, CSIDL_MYDOCUMENTS, TRUE);
|
||||
|
@ -2248,7 +2249,24 @@ HRESULT DoCreateSendToFiles(LPCWSTR pszSendTo)
|
|||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
CloseHandle(hFile);
|
||||
|
||||
return hr;
|
||||
/* create zipped compressed folder */
|
||||
hZipFldr = LoadLibraryW(L"zipfldr.dll");
|
||||
if (hZipFldr)
|
||||
{
|
||||
#define IDS_FRIENDLYNAME 10195
|
||||
LoadStringW(hZipFldr, IDS_FRIENDLYNAME, szTarget, _countof(szTarget));
|
||||
#undef IDS_FRIENDLYNAME
|
||||
FreeLibrary(hZipFldr);
|
||||
|
||||
StringCbCopyW(szSendToFile, sizeof(szSendToFile), pszSendTo);
|
||||
PathAppendW(szSendToFile, szTarget);
|
||||
StringCbCatW(szSendToFile, sizeof(szSendToFile), L".ZFSendToTarget");
|
||||
hFile = CreateFileW(szSendToFile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
|
Loading…
Reference in a new issue