| 1626 | |
| 1627 | |
| 1628 | wchar_t * tinyfd_saveFileDialogW( |
| 1629 | wchar_t const * aTitle, /* NULL or "" */ |
| 1630 | wchar_t const * aDefaultPathAndOrFile, /* NULL or "" */ |
| 1631 | int aNumOfFilterPatterns, /* 0 */ |
| 1632 | wchar_t const * const * aFilterPatterns, /* NULL or {"*.jpg","*.png"} */ |
| 1633 | wchar_t const * aSingleFilterDescription) /* NULL or "image files" */ |
| 1634 | { |
| 1635 | static wchar_t lBuff[MAX_PATH_OR_CMD]; |
| 1636 | wchar_t lDirname[MAX_PATH_OR_CMD]; |
| 1637 | wchar_t lDialogString[MAX_PATH_OR_CMD]; |
| 1638 | wchar_t lFilterPatterns[MAX_PATH_OR_CMD] = L""; |
| 1639 | wchar_t * p; |
| 1640 | wchar_t * lRetval; |
| 1641 | wchar_t const * ldefExt = NULL; |
| 1642 | int i; |
| 1643 | HRESULT lHResult; |
| 1644 | OPENFILENAMEW ofn = {0}; |
| 1645 | |
| 1646 | if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return (wchar_t *)1; } |
| 1647 | |
| 1648 | /*if (quoteDetectedW(aTitle)) return tinyfd_saveFileDialogW(L"INVALID TITLE WITH QUOTES", aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription); |
| 1649 | if (quoteDetectedW(aDefaultPathAndOrFile)) return tinyfd_saveFileDialogW(aTitle, L"INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription); |
| 1650 | if (quoteDetectedW(aSingleFilterDescription)) return tinyfd_saveFileDialogW(aTitle, aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, L"INVALID FILTER_DESCRIPTION WITH QUOTES"); |
| 1651 | for (i = 0; i < aNumOfFilterPatterns; i++) |
| 1652 | { |
| 1653 | if (quoteDetectedW(aFilterPatterns[i])) return tinyfd_saveFileDialogW(L"INVALID FILTER_PATTERN WITH QUOTES: use the GRAVE ACCENT \\x60 instead.", aDefaultPathAndOrFile, 0, NULL, NULL); |
| 1654 | }*/ |
| 1655 | |
| 1656 | lHResult = CoInitializeEx(NULL, 0); |
| 1657 | |
| 1658 | getPathWithoutFinalSlashW(lDirname, aDefaultPathAndOrFile); |
| 1659 | getLastNameW(lBuff, aDefaultPathAndOrFile); |
| 1660 | |
| 1661 | if (aNumOfFilterPatterns > 0) |
| 1662 | { |
| 1663 | ldefExt = aFilterPatterns[0]; |
| 1664 | |
| 1665 | if (aSingleFilterDescription && wcslen(aSingleFilterDescription)) |
| 1666 | { |
| 1667 | wcscpy(lFilterPatterns, aSingleFilterDescription); |
| 1668 | wcscat(lFilterPatterns, L"\n"); |
| 1669 | } |
| 1670 | wcscat(lFilterPatterns, aFilterPatterns[0]); |
| 1671 | for (i = 1; i < aNumOfFilterPatterns; i++) |
| 1672 | { |
| 1673 | wcscat(lFilterPatterns, L";"); |
| 1674 | wcscat(lFilterPatterns, aFilterPatterns[i]); |
| 1675 | } |
| 1676 | wcscat(lFilterPatterns, L"\n"); |
| 1677 | if (!(aSingleFilterDescription && wcslen(aSingleFilterDescription))) |
| 1678 | { |
| 1679 | wcscpy(lDialogString, lFilterPatterns); |
| 1680 | wcscat(lFilterPatterns, lDialogString); |
| 1681 | } |
| 1682 | wcscat(lFilterPatterns, L"All Files\n*.*\n"); |
| 1683 | p = lFilterPatterns; |
| 1684 | while ((p = wcschr(p, L'\n')) != NULL) |
| 1685 | { |
no test coverage detected