source: trunk/src/comdlg32/filetitle.c@ 2607

Last change on this file since 2607 was 2607, checked in by sandervl, 26 years ago

merged with latest wine code

File size: 1.9 KB
Line 
1/*
2 * COMMDLG - File Dialogs
3 *
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
6 */
7
8#include <string.h>
9
10#include "wine/winestring.h"
11#include "winbase.h"
12#include "commdlg.h"
13#include "debugtools.h"
14
15#include "heap.h" /* Has to go */
16
17DEFAULT_DEBUG_CHANNEL(commdlg)
18
19#include "cdlg.h"
20
21#ifdef __WIN32OS2__
22#include <misc.h>
23#endif
24
25/***********************************************************************
26 * GetFileTitleA (COMDLG32.8)
27 *
28 */
29short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
30{
31 int i, len;
32
33 TRACE("(%p %p %d); \n", lpFile, lpTitle, cbBuf);
34
35 if(lpFile == NULL || (lpTitle == NULL && cbBuf != 0))
36 return -1;
37
38 len = strlen(lpFile);
39
40 if (len == 0)
41 return -1;
42
43 if(strpbrk(lpFile, "*[]"))
44 return -1;
45
46 len--;
47
48 if(lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
49 return -1;
50
51 for(i = len; i >= 0; i--)
52 {
53 if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':')
54 {
55 i++;
56 break;
57 }
58 }
59
60 if(i == -1)
61 i++;
62
63 TRACE("---> '%s' \n", &lpFile[i]);
64
65 len = strlen(lpFile+i)+1;
66 if(cbBuf < len)
67 return len;
68
69 /* The lpTitle buffer is big enough, perform a simple copy */
70 strcpy(lpTitle, &lpFile[i]);
71 return 0;
72}
73
74
75/***********************************************************************
76 * GetFileTitleW (COMDLG32.9)
77 *
78 */
79short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, UINT cbBuf)
80{
81 LPSTR file = HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile); /* Has to go */
82 LPSTR title = HeapAlloc(GetProcessHeap(), 0, cbBuf);
83 short ret;
84
85 ret = GetFileTitleA(file, title, cbBuf);
86
87 lstrcpynAtoW(lpTitle, title, cbBuf);
88 HeapFree(GetProcessHeap(), 0, file);
89 HeapFree(GetProcessHeap(), 0, title);
90 return ret;
91}
92
93
94/***********************************************************************
95 * GetFileTitle16 (COMMDLG.27)
96 */
97short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
98{
99 return GetFileTitleA(lpFile, lpTitle, cbBuf);
100}
101
Note: See TracBrowser for help on using the repository browser.