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