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

Last change on this file since 6645 was 6645, checked in by bird, 24 years ago

Added $Id:$ keyword.

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