1999-04-25 20:31:35 +02:00
|
|
|
/*
|
|
|
|
* COMMDLG - File Dialogs
|
|
|
|
*
|
|
|
|
* Copyright 1994 Martin Ayotte
|
|
|
|
* Copyright 1996 Albrecht Kleine
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "winbase.h"
|
2000-11-28 23:40:56 +01:00
|
|
|
#include "winnls.h"
|
1999-04-25 20:31:35 +02:00
|
|
|
#include "commdlg.h"
|
1999-06-12 17:45:58 +02:00
|
|
|
#include "debugtools.h"
|
1999-04-25 20:31:35 +02:00
|
|
|
|
|
|
|
#include "heap.h" /* Has to go */
|
|
|
|
|
2000-11-28 00:54:25 +01:00
|
|
|
DEFAULT_DEBUG_CHANNEL(commdlg);
|
1999-04-25 20:31:35 +02:00
|
|
|
|
|
|
|
#include "cdlg.h"
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* GetFileTitleA (COMDLG32.@)
|
1999-04-25 20:31:35 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
|
|
|
|
{
|
|
|
|
int i, len;
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p %p %d); \n", lpFile, lpTitle, cbBuf);
|
1999-04-25 20:31:35 +02:00
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
if(lpFile == NULL || lpTitle == NULL)
|
1999-04-25 20:31:35 +02:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
len = strlen(lpFile);
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if(strpbrk(lpFile, "*[]"))
|
|
|
|
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++;
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("---> '%s' \n", &lpFile[i]);
|
1999-04-25 20:31:35 +02:00
|
|
|
|
|
|
|
len = strlen(lpFile+i)+1;
|
|
|
|
if(cbBuf < len)
|
|
|
|
return len;
|
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
strncpy(lpTitle, &lpFile[i], len);
|
1999-04-25 20:31:35 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* GetFileTitleW (COMDLG32.@)
|
1999-04-25 20:31:35 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, UINT cbBuf)
|
|
|
|
{
|
|
|
|
LPSTR file = HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile); /* Has to go */
|
|
|
|
LPSTR title = HeapAlloc(GetProcessHeap(), 0, cbBuf);
|
|
|
|
short ret;
|
|
|
|
|
|
|
|
ret = GetFileTitleA(file, title, cbBuf);
|
|
|
|
|
2000-11-28 23:40:56 +01:00
|
|
|
if (cbBuf > 0 && !MultiByteToWideChar( CP_ACP, 0, title, -1, lpTitle, cbBuf ))
|
|
|
|
lpTitle[cbBuf-1] = 0;
|
1999-04-25 20:31:35 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, file);
|
|
|
|
HeapFree(GetProcessHeap(), 0, title);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* GetFileTitle (COMMDLG.27)
|
1999-04-25 20:31:35 +02:00
|
|
|
*/
|
|
|
|
short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
|
|
|
|
{
|
|
|
|
return GetFileTitleA(lpFile, lpTitle, cbBuf);
|
|
|
|
}
|
|
|
|
|