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
27 #include "wine/debug.h"
29 #include "heap.h" /* Has to go */
31 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
35 /***********************************************************************
36 * GetFileTitleA (COMDLG32.@)
39 short WINAPI
GetFileTitleA(LPCSTR lpFile
, LPSTR lpTitle
, UINT cbBuf
)
43 TRACE("(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
45 if(lpFile
== NULL
|| lpTitle
== NULL
)
53 if(strpbrk(lpFile
, "*[]"))
58 if(lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
61 for(i
= len
; i
>= 0; i
--)
63 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
73 TRACE("---> '%s' \n", &lpFile
[i
]);
75 len
= strlen(lpFile
+i
)+1;
79 strncpy(lpTitle
, &lpFile
[i
], len
);
84 /***********************************************************************
85 * GetFileTitleW (COMDLG32.@)
88 short WINAPI
GetFileTitleW(LPCWSTR lpFile
, LPWSTR lpTitle
, UINT cbBuf
)
90 LPSTR file
= HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile
); /* Has to go */
91 LPSTR title
= HeapAlloc(GetProcessHeap(), 0, cbBuf
);
94 ret
= GetFileTitleA(file
, title
, cbBuf
);
96 if (cbBuf
> 0 && !MultiByteToWideChar( CP_ACP
, 0, title
, -1, lpTitle
, cbBuf
))
98 HeapFree(GetProcessHeap(), 0, file
);
99 HeapFree(GetProcessHeap(), 0, title
);
104 /***********************************************************************
105 * GetFileTitle (COMMDLG.27)
107 short WINAPI
GetFileTitle16(LPCSTR lpFile
, LPSTR lpTitle
, UINT16 cbBuf
)
109 return GetFileTitleA(lpFile
, lpTitle
, cbBuf
);