2 * COMMDLG - File Dialogs
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
39 /***********************************************************************
40 * GetFileTitleA (COMDLG32.@)
43 short WINAPI
GetFileTitleA(LPCSTR lpFile
, LPSTR lpTitle
, WORD cbBuf
)
46 UNICODE_STRING strWFile
;
49 RtlCreateUnicodeStringFromAsciiz(&strWFile
, lpFile
);
50 lpWTitle
= RtlAllocateHeap( GetProcessHeap(), 0, cbBuf
*sizeof(WCHAR
));
51 ret
= GetFileTitleW(strWFile
.Buffer
, lpWTitle
, cbBuf
);
52 if (!ret
) WideCharToMultiByte( CP_ACP
, 0, lpWTitle
, -1, lpTitle
, cbBuf
, NULL
, NULL
);
53 RtlFreeUnicodeString( &strWFile
);
54 RtlFreeHeap( GetProcessHeap(), 0, lpWTitle
);
59 /***********************************************************************
60 * GetFileTitleW (COMDLG32.@)
63 short WINAPI
GetFileTitleW(LPCWSTR lpFile
, LPWSTR lpTitle
, WORD cbBuf
)
66 static const WCHAR brkpoint
[] = {'*','[',']',0};
67 TRACE("(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
69 if(lpFile
== NULL
|| lpTitle
== NULL
)
72 len
= strlenW(lpFile
);
77 if(strpbrkW(lpFile
, brkpoint
))
82 if(lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
85 for(i
= len
; i
>= 0; i
--)
87 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
97 TRACE("---> '%s' \n", debugstr_w(&lpFile
[i
]));
99 len
= strlenW(lpFile
+i
)+1;
103 strcpyW(lpTitle
, &lpFile
[i
]);
108 /***********************************************************************
109 * GetFileTitle (COMMDLG.27)
111 short WINAPI
GetFileTitle16(LPCSTR lpFile
, LPSTR lpTitle
, UINT16 cbBuf
)
113 return GetFileTitleA(lpFile
, lpTitle
, cbBuf
);