[2607] | 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 |
|
---|
[6709] | 15 | #include "heap.h" /* Has to go */
|
---|
[2607] | 16 |
|
---|
| 17 | DEFAULT_DEBUG_CHANNEL(commdlg)
|
---|
| 18 |
|
---|
| 19 | #include "cdlg.h"
|
---|
| 20 |
|
---|
| 21 | /***********************************************************************
|
---|
[6709] | 22 | * GetFileTitleA (COMDLG32.8)
|
---|
[2607] | 23 | *
|
---|
| 24 | */
|
---|
| 25 | short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
|
---|
| 26 | {
|
---|
[6709] | 27 | int i, len;
|
---|
[2607] | 28 |
|
---|
[6709] | 29 | TRACE("(%p %p %d); \n", lpFile, lpTitle, cbBuf);
|
---|
[2607] | 30 |
|
---|
[6709] | 31 | if(lpFile == NULL || lpTitle == NULL)
|
---|
| 32 | return -1;
|
---|
[2607] | 33 |
|
---|
[6709] | 34 | len = strlen(lpFile);
|
---|
[2607] | 35 |
|
---|
[6709] | 36 | if (len == 0)
|
---|
| 37 | return -1;
|
---|
[2607] | 38 |
|
---|
[6709] | 39 | if(strpbrk(lpFile, "*[]"))
|
---|
| 40 | return -1;
|
---|
[2607] | 41 |
|
---|
[6709] | 42 | len--;
|
---|
[2607] | 43 |
|
---|
[6709] | 44 | if(lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
|
---|
| 45 | return -1;
|
---|
[2607] | 46 |
|
---|
[6709] | 47 | for(i = len; i >= 0; i--)
|
---|
| 48 | {
|
---|
| 49 | if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':')
|
---|
| 50 | {
|
---|
| 51 | i++;
|
---|
| 52 | break;
|
---|
| 53 | }
|
---|
| 54 | }
|
---|
[2607] | 55 |
|
---|
[6709] | 56 | if(i == -1)
|
---|
| 57 | i++;
|
---|
[2607] | 58 |
|
---|
[6709] | 59 | TRACE("---> '%s' \n", &lpFile[i]);
|
---|
| 60 |
|
---|
| 61 | len = strlen(lpFile+i)+1;
|
---|
| 62 | if(cbBuf < len)
|
---|
| 63 | return len;
|
---|
[2607] | 64 |
|
---|
[6709] | 65 | strncpy(lpTitle, &lpFile[i], len);
|
---|
| 66 | return 0;
|
---|
[2607] | 67 | }
|
---|
| 68 |
|
---|
| 69 |
|
---|
| 70 | /***********************************************************************
|
---|
[6709] | 71 | * GetFileTitleW (COMDLG32.9)
|
---|
[2607] | 72 | *
|
---|
| 73 | */
|
---|
| 74 | short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, UINT cbBuf)
|
---|
| 75 | {
|
---|
[6709] | 76 | LPSTR file = HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile); /* Has to go */
|
---|
| 77 | LPSTR title = HeapAlloc(GetProcessHeap(), 0, cbBuf);
|
---|
| 78 | short ret;
|
---|
[2607] | 79 |
|
---|
[6709] | 80 | ret = GetFileTitleA(file, title, cbBuf);
|
---|
[2607] | 81 |
|
---|
[6709] | 82 | lstrcpynAtoW(lpTitle, title, cbBuf);
|
---|
| 83 | HeapFree(GetProcessHeap(), 0, file);
|
---|
| 84 | HeapFree(GetProcessHeap(), 0, title);
|
---|
| 85 | return ret;
|
---|
[2607] | 86 | }
|
---|
| 87 |
|
---|
| 88 |
|
---|
[4511] | 89 | #ifndef __WIN32OS2__
|
---|
[2607] | 90 | /***********************************************************************
|
---|
[6709] | 91 | * GetFileTitle16 (COMMDLG.27)
|
---|
[2607] | 92 | */
|
---|
| 93 | short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
|
---|
| 94 | {
|
---|
[6709] | 95 | return GetFileTitleA(lpFile, lpTitle, cbBuf);
|
---|
[2607] | 96 | }
|
---|
[4511] | 97 | #endif
|
---|
[2607] | 98 |
|
---|