Francois Gouget <fgouget@free.fr>

- Make Unicode const strings static so they are not copied to the stack
  each time we enter the function.
Aric Stewart <aric@codeweavers.com>
- In IPersistFile_Save if the exe file is not found, trust the path we
  are given and allow creation of the link.
- Make sure exePath contains the path since it is used later in the
  function as well.
Ge van Geldorp <gvg@reactos.com>
- Match whitespace to winehq

svn path=/trunk/; revision=10950
This commit is contained in:
Gé van Geldorp 2004-09-20 21:39:04 +00:00
parent 093f4a09c5
commit 822b8e1a47

View file

@ -248,7 +248,7 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFile
static BOOL StartLinkProcessor( LPCOLESTR szLink )
{
const WCHAR szFormat[] = {'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',
static const WCHAR szFormat[] = {'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',
' ','-','r',' ','"','%','s','"',0 };
LONG len;
LPWSTR buffer;
@ -524,7 +524,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
TRACE("(%p)(%p)\n", This, stm);
if( !stm )
return STG_E_INVALIDPOINTER;
return STG_E_INVALIDPOINTER;
dwBytesRead = 0;
r = IStream_Read(stm, &hdr, sizeof(hdr), &dwBytesRead);
@ -538,7 +538,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
if( !IsEqualIID(&hdr.MagicGuid, &CLSID_ShellLink) )
return E_FAIL;
if( hdr.dwFlags & SCF_PIDL )
/* if( hdr.dwFlags & SCF_PIDL ) */ /* FIXME: seems to always have a PIDL */
{
r = ILLoadFromStream( stm, &This->pPidl );
if( FAILED( r ) )
@ -580,7 +580,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
goto end;
if( hdr.dwFlags & SCF_WORKDIR )
{
{
r = Stream_LoadString( stm, unicode, &This->sWorkDir );
TRACE("Working Dir -> %s\n",debugstr_w(This->sWorkDir));
}
@ -676,16 +676,18 @@ static HRESULT WINAPI IPersistStream_fnSave(
*exePath = '\0';
if (This->sPath)
SHELL_FindExecutable(NULL, This->sPath, wOpen, exePath, MAX_PATH, NULL, NULL, NULL, NULL);
{
SHELL_FindExecutable(NULL, This->sPath, wOpen, exePath, MAX_PATH, NULL, NULL, NULL, NULL);
/*
* windows can create lnk files to executables that do not exist yet
* so if the executable does not exist the just trust the path they
* gave us
*/
if( !*exePath ) strcpyW(exePath,This->sPath);
}
/* if there's no PIDL, generate one */
if( ! This->pPidl )
{
if( !*exePath )
return E_FAIL;
This->pPidl = ILCreateFromPathW(exePath);
}
if( ! This->pPidl ) This->pPidl = ILCreateFromPathW(exePath);
memset(&header, 0, sizeof(header));
header.dwSize = sizeof(header);
@ -820,6 +822,7 @@ HRESULT WINAPI IShellLink_Constructor (
return S_OK;
}
static BOOL SHELL_ExistsFileW(LPCWSTR path)
{
HANDLE hfile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
@ -936,7 +939,7 @@ HRESULT WINAPI IShellLink_ConstructFromFile (
/**************************************************************************
* IShellLinkA_QueryInterface
*/
static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID riid, LPVOID *ppvObj)
static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID riid, LPVOID *ppvObj)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
@ -971,7 +974,6 @@ static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID
TRACE("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
/******************************************************************************
* IShellLinkA_AddRef
*/
@ -983,7 +985,6 @@ static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface)
return ++(This->ref);
}
/******************************************************************************
* IShellLinkA_Release
*/
@ -1011,7 +1012,7 @@ static ULONG WINAPI IShellLinkA_fnRelease(IShellLinkA * iface)
HeapFree(GetProcessHeap(), 0, This->sDescription);
if (This->sPath)
HeapFree(GetProcessHeap(), 0, This->sPath);
HeapFree(GetProcessHeap(),0,This->sPath);
if (This->pPidl)
ILFree(This->pPidl);
@ -1062,8 +1063,7 @@ static HRESULT WINAPI IShellLinkA_fnSetIDList(IShellLinkA * iface, LPCITEMIDLIST
TRACE("(%p)->(pidl=%p)\n",This, pidl);
if (This->pPidl)
ILFree(This->pPidl);
ILFree(This->pPidl);
This->pPidl = ILClone (pidl);
This->bDirty = TRUE;
@ -1178,14 +1178,14 @@ static HRESULT WINAPI IShellLinkA_fnGetHotkey(IShellLinkA * iface, WORD *pwHotke
static HRESULT WINAPI IShellLinkA_fnSetHotkey(IShellLinkA * iface, WORD wHotkey)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(hotkey=%x)\n",This, wHotkey);
TRACE("(%p)->(hotkey=%x)\n",This, wHotkey);
This->wHotKey = wHotkey;
This->bDirty = TRUE;
This->wHotKey = wHotkey;
This->bDirty = TRUE;
return S_OK;
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnGetShowCmd(IShellLinkA * iface, INT *piShowCmd)
@ -1232,7 +1232,7 @@ static HRESULT SHELL_PidlGeticonLocationA(IShellFolder* psf, LPITEMIDLIST pidl,
return hr;
}
static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR pszIconPath, INT cchIconPath, INT *piIcon)
static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR pszIconPath,INT cchIconPath,INT *piIcon)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
@ -1280,7 +1280,7 @@ static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR p
return E_FAIL;
}
static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR pszIconPath, INT iIcon)
static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR pszIconPath,INT iIcon)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
@ -1306,7 +1306,6 @@ static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA * iface, LPCSTR
if (This->sPathRel)
HeapFree(GetProcessHeap(), 0, This->sPathRel);
This->sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel);
This->bDirty = TRUE;
@ -1553,7 +1552,6 @@ static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPC
(lstrlenW( pszDir )+1)*sizeof (WCHAR) );
if ( !This->sWorkDir )
return E_OUTOFMEMORY;
lstrcpyW( This->sWorkDir, pszDir );
This->bDirty = TRUE;
@ -1586,7 +1584,6 @@ static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR ps
(lstrlenW( pszArgs )+1)*sizeof (WCHAR) );
if ( !This->sArgs )
return E_OUTOFMEMORY;
lstrcpyW( This->sArgs, pszArgs );
This->bDirty = TRUE;
@ -1660,7 +1657,7 @@ static HRESULT SHELL_PidlGeticonLocationW(IShellFolder* psf, LPITEMIDLIST pidl,
return hr;
}
static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath, INT cchIconPath, INT *piIcon)
static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath,INT cchIconPath,INT *piIcon)
{
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
@ -1708,7 +1705,7 @@ static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR
return E_FAIL;
}
static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath, INT iIcon)
static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath,INT iIcon)
{
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
@ -1740,7 +1737,6 @@ static HRESULT WINAPI IShellLinkW_fnSetRelativePath(IShellLinkW * iface, LPCWSTR
(lstrlenW( pszPathRel )+1) * sizeof (WCHAR) );
if ( !This->sPathRel )
return E_OUTOFMEMORY;
lstrcpyW( This->sPathRel, pszPathRel );
This->bDirty = TRUE;