diff --git a/apilibs/kexbasen/kexbasen.dsp b/apilibs/kexbasen/kexbasen.dsp index ddd8390..8c382d3 100755 --- a/apilibs/kexbasen/kexbasen.dsp +++ b/apilibs/kexbasen/kexbasen.dsp @@ -253,6 +253,10 @@ SOURCE=.\shell32\SHParseDisplayName.c # End Source File # Begin Source File +SOURCE=.\shell32\SHPathPrepareForWrite.c +# End Source File +# Begin Source File + SOURCE=.\shell32\unishell32.c # End Source File # End Group diff --git a/apilibs/kexbasen/shell32/SHPathPrepareForWrite.c b/apilibs/kexbasen/shell32/SHPathPrepareForWrite.c new file mode 100755 index 0000000..9ecdb78 --- /dev/null +++ b/apilibs/kexbasen/shell32/SHPathPrepareForWrite.c @@ -0,0 +1,99 @@ +/* + * KernelEx + * Copyright (C) 2018, Uzix + * Copyright (C) the Wine project + * + * This file is part of KernelEx source code. + * + * KernelEx is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 of the License. + * + * KernelEx is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#if defined(_WIN32_IE) && _WIN32_IE != 0x0601 +#undef _WIN32_IE +#endif +#define _WIN32_IE 0x0601 +#include +#include "common.h" + + + +/* MAKE_EXPORT SHPathPrepareForWriteA_new=SHPathPrepareForWriteA */ +HRESULT WINAPI SHPathPrepareForWriteA_new(HWND hwnd, IUnknown *punkEnableModless, LPCSTR pszPathA, DWORD dwFlags) +{ + DWORD res; + DWORD err; + LPCSTR realpath; + int len; + CHAR* last_slash; + CHAR* temppath=NULL; + + if (dwFlags & ~(SHPPFW_DIRCREATE|SHPPFW_ASKDIRCREATE|SHPPFW_IGNOREFILENAME)) { + /* FIXME: unimplemented flags */ + } + + /* cut off filename if necessary */ + if (dwFlags & SHPPFW_IGNOREFILENAME) + { + last_slash = strrchr(pszPathA, '\\'); + if (last_slash == NULL) + len = 1; + else + len = last_slash - pszPathA + 1; + temppath = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR)); + if (!temppath) + return E_OUTOFMEMORY; + lstrcpynA(temppath, pszPathA, len); + realpath = temppath; + } + else + { + realpath = pszPathA; + } + + /* try to create the directory if asked to */ + if (dwFlags & (SHPPFW_DIRCREATE|SHPPFW_ASKDIRCREATE)) + { + if (dwFlags & SHPPFW_ASKDIRCREATE) { + /* FIXME: treating SHPPFW_ASKDIRCREATE as SHPPFW_DIRCREATE */ + } + + SHCreateDirectoryExA(hwnd, realpath, NULL); + } + + /* check if we can access the directory */ + res = GetFileAttributesA(realpath); + + HeapFree(GetProcessHeap(), 0, temppath); + + if (res == INVALID_FILE_ATTRIBUTES) + { + err = GetLastError(); + if (err == ERROR_FILE_NOT_FOUND) + return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); + return HRESULT_FROM_WIN32(err); + } + else if (res & FILE_ATTRIBUTE_DIRECTORY) + return S_OK; + else + return HRESULT_FROM_WIN32(ERROR_DIRECTORY); +} + + +/* MAKE_EXPORT SHPathPrepareForWriteW_new=SHPathPrepareForWriteW */ +HRESULT WINAPI SHPathPrepareForWriteW_new(HWND hwnd, IUnknown *punkEnableModless, LPCWSTR pszPathW, DWORD dwFlags) +{ + ALLOC_WtoA(pszPath); + return SHPathPrepareForWriteA_new(hwnd, punkEnableModless, pszPathA, dwFlags); +} diff --git a/apilibs/kexbasen/shell32/_shell32_apilist.c b/apilibs/kexbasen/shell32/_shell32_apilist.c index a4e75ec..d31d3ce 100755 --- a/apilibs/kexbasen/shell32/_shell32_apilist.c +++ b/apilibs/kexbasen/shell32/_shell32_apilist.c @@ -56,6 +56,8 @@ static const apilib_named_api shell32_named_apis[] = DECL_API("SHGetSpecialFolderPathA", SHGetSpecialFolderPathA_new), DECL_API("SHGetSpecialFolderPathW", SHGetSpecialFolderPathW_new), DECL_API("SHParseDisplayName", SHParseDisplayName_new), + DECL_API("SHPathPrepareForWriteA", SHPathPrepareForWriteA_new), + DECL_API("SHPathPrepareForWriteW", SHPathPrepareForWriteW_new), DECL_API("ShellAboutW", ShellAboutW_fwd), DECL_API("ShellExecuteExW", ShellExecuteExW_fwd), DECL_API("ShellExecuteW", ShellExecuteW_fwd), diff --git a/apilibs/kexbasen/shell32/_shell32_apilist.h b/apilibs/kexbasen/shell32/_shell32_apilist.h index b4bb5ef..df7cf3c 100755 --- a/apilibs/kexbasen/shell32/_shell32_apilist.h +++ b/apilibs/kexbasen/shell32/_shell32_apilist.h @@ -41,6 +41,8 @@ HRESULT WINAPI SHGetSpecialFolderLocation_fix(HWND hwndOwner, int nFolder, LPVOI BOOL WINAPI SHGetSpecialFolderPathA_new(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate); BOOL WINAPI SHGetSpecialFolderPathW_new(HWND hwndOwner, LPWSTR lpszPathW, int nFolder, BOOL fCreate); HRESULT WINAPI SHParseDisplayName_new(PCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut); +HRESULT WINAPI SHPathPrepareForWriteA_new(HWND hwnd, IUnknown *punkEnableModless, LPCSTR pszPathA, DWORD dwFlags); +HRESULT WINAPI SHPathPrepareForWriteW_new(HWND hwnd, IUnknown *punkEnableModless, LPCWSTR pszPathW, DWORD dwFlags); FWDPROC ExtractIconExW_fwd; FWDPROC ExtractIconW_fwd; FWDPROC FindExecutableW_fwd;