source: trunk/src/comdlg32/filetitle.cpp@ 1557

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

Wine 991031 update

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