1999-04-25 18:31:35 +00:00
|
|
|
/*
|
|
|
|
* COMMDLG - File Dialogs
|
|
|
|
*
|
|
|
|
* Copyright 1994 Martin Ayotte
|
|
|
|
* Copyright 1996 Albrecht Kleine
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-04-25 18:31:35 +00:00
|
|
|
*/
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
1999-04-25 18:31:35 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "windef.h"
|
1999-04-25 18:31:35 +00:00
|
|
|
#include "winbase.h"
|
2000-11-28 22:40:56 +00:00
|
|
|
#include "winnls.h"
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "winreg.h"
|
2003-01-21 19:32:21 +00:00
|
|
|
#include "winternl.h"
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
1999-04-25 18:31:35 +00:00
|
|
|
#include "commdlg.h"
|
2003-01-21 19:32:21 +00:00
|
|
|
#include "cdlg.h"
|
2005-06-28 19:19:07 +00:00
|
|
|
#include "cdlg16.h"
|
2003-01-21 19:32:21 +00:00
|
|
|
#include "wine/unicode.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
1999-04-25 18:31:35 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
1999-04-25 18:31:35 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 03:34:07 +00:00
|
|
|
* GetFileTitleA (COMDLG32.@)
|
1999-04-25 18:31:35 +00:00
|
|
|
*
|
2005-11-12 19:12:25 +00:00
|
|
|
* See GetFileTitleW.
|
1999-04-25 18:31:35 +00:00
|
|
|
*/
|
2004-03-12 01:52:11 +00:00
|
|
|
short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, WORD cbBuf)
|
1999-04-25 18:31:35 +00:00
|
|
|
{
|
2003-01-21 19:32:21 +00:00
|
|
|
int ret;
|
|
|
|
UNICODE_STRING strWFile;
|
|
|
|
LPWSTR lpWTitle;
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&strWFile, lpFile);
|
|
|
|
lpWTitle = RtlAllocateHeap( GetProcessHeap(), 0, cbBuf*sizeof(WCHAR));
|
|
|
|
ret = GetFileTitleW(strWFile.Buffer, lpWTitle, cbBuf);
|
|
|
|
if (!ret) WideCharToMultiByte( CP_ACP, 0, lpWTitle, -1, lpTitle, cbBuf, NULL, NULL );
|
|
|
|
RtlFreeUnicodeString( &strWFile );
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, lpWTitle );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-04-25 18:31:35 +00:00
|
|
|
|
2003-01-21 19:32:21 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetFileTitleW (COMDLG32.@)
|
|
|
|
*
|
2005-11-12 19:12:25 +00:00
|
|
|
* Get the name of a file.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpFile [I] name and location of file
|
|
|
|
* lpTitle [O] returned file name
|
|
|
|
* cbBuf [I] buffer size of lpTitle
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: zero
|
|
|
|
* Failure: negative number.
|
2003-01-21 19:32:21 +00:00
|
|
|
*/
|
2004-03-12 01:52:11 +00:00
|
|
|
short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, WORD cbBuf)
|
2003-01-21 19:32:21 +00:00
|
|
|
{
|
|
|
|
int i, len;
|
2003-03-30 03:05:55 +00:00
|
|
|
static const WCHAR brkpoint[] = {'*','[',']',0};
|
2005-11-10 12:14:56 +00:00
|
|
|
TRACE("(%p %p %d);\n", lpFile, lpTitle, cbBuf);
|
1999-04-25 18:31:35 +00:00
|
|
|
|
2000-02-20 18:54:04 +00:00
|
|
|
if(lpFile == NULL || lpTitle == NULL)
|
1999-04-25 18:31:35 +00:00
|
|
|
return -1;
|
|
|
|
|
2003-01-21 19:32:21 +00:00
|
|
|
len = strlenW(lpFile);
|
1999-04-25 18:31:35 +00:00
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
return -1;
|
|
|
|
|
2003-01-21 19:32:21 +00:00
|
|
|
if(strpbrkW(lpFile, brkpoint))
|
1999-04-25 18:31:35 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
len--;
|
|
|
|
|
|
|
|
if(lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
for(i = len; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':')
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i == -1)
|
|
|
|
i++;
|
|
|
|
|
2005-11-10 12:14:56 +00:00
|
|
|
TRACE("---> '%s'\n", debugstr_w(&lpFile[i]));
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2003-01-21 19:32:21 +00:00
|
|
|
len = strlenW(lpFile+i)+1;
|
1999-04-25 18:31:35 +00:00
|
|
|
if(cbBuf < len)
|
|
|
|
return len;
|
|
|
|
|
2003-01-21 19:32:21 +00:00
|
|
|
strcpyW(lpTitle, &lpFile[i]);
|
1999-04-25 18:31:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* GetFileTitle (COMMDLG.27)
|
1999-04-25 18:31:35 +00:00
|
|
|
*/
|
|
|
|
short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
|
|
|
|
{
|
|
|
|
return GetFileTitleA(lpFile, lpTitle, cbBuf);
|
|
|
|
}
|