MCPcopy Create free account
hub / github.com/black-sliver/PopTracker / tinyfd_openFileDialogW

Function tinyfd_openFileDialogW

lib/tinyfiledialogs/tinyfiledialogs.cpp:1730–1895  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1728
1729
1730wchar_t * tinyfd_openFileDialogW(
1731 wchar_t const * aTitle, /* NULL or "" */
1732 wchar_t const * aDefaultPathAndOrFile, /* NULL or "" */
1733 int aNumOfFilterPatterns, /* 0 */
1734 wchar_t const * const * aFilterPatterns, /* NULL or {"*.jpg","*.png"} */
1735 wchar_t const * aSingleFilterDescription, /* NULL or "image files" */
1736 int aAllowMultipleSelects) /* 0 or 1 ; -1 to free allocated memory and return */
1737{
1738 size_t lLengths[MAX_MULTIPLE_FILES];
1739 wchar_t lDirname[MAX_PATH_OR_CMD];
1740 wchar_t lFilterPatterns[MAX_PATH_OR_CMD] = L"";
1741 wchar_t lDialogString[MAX_PATH_OR_CMD];
1742 wchar_t * lPointers[MAX_MULTIPLE_FILES+1];
1743 wchar_t * p;
1744 int i, j;
1745 size_t lBuffLen;
1746 DWORD lFullBuffLen;
1747 HRESULT lHResult;
1748 OPENFILENAMEW ofn = { 0 };
1749 static wchar_t * lBuff = NULL;
1750
1751 free(lBuff);
1752 lBuff = NULL;
1753 if (aAllowMultipleSelects < 0) return (wchar_t *)0;
1754
1755 if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return (wchar_t *)1; }
1756
1757 /*if (quoteDetectedW(aTitle)) return tinyfd_openFileDialogW(L"INVALID TITLE WITH QUOTES", aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
1758 if (quoteDetectedW(aDefaultPathAndOrFile)) return tinyfd_openFileDialogW(aTitle, L"INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
1759 if (quoteDetectedW(aSingleFilterDescription)) return tinyfd_openFileDialogW(aTitle, aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, L"INVALID FILTER_DESCRIPTION WITH QUOTES", aAllowMultipleSelects);
1760 for (i = 0; i < aNumOfFilterPatterns; i++)
1761 {
1762 if (quoteDetectedW(aFilterPatterns[i])) return tinyfd_openFileDialogW(L"INVALID FILTER_PATTERN WITH QUOTES: use the GRAVE ACCENT \\x60 instead.", aDefaultPathAndOrFile, 0, NULL, NULL, aAllowMultipleSelects);
1763 }*/
1764
1765 if (aAllowMultipleSelects)
1766 {
1767 lFullBuffLen = MAX_MULTIPLE_FILES * MAX_PATH_OR_CMD + 1;
1768 lBuff = (wchar_t*) malloc(lFullBuffLen * sizeof(wchar_t));
1769 if (!lBuff)
1770 {
1771 lFullBuffLen = LOW_MULTIPLE_FILES * MAX_PATH_OR_CMD + 1;
1772 lBuff = (wchar_t*) malloc( lFullBuffLen * sizeof(wchar_t));
1773 }
1774 }
1775 else
1776 {
1777 lFullBuffLen = MAX_PATH_OR_CMD + 1;
1778 lBuff = (wchar_t*) malloc(lFullBuffLen * sizeof(wchar_t));
1779 }
1780 if (!lBuff) return NULL;
1781
1782 lHResult = CoInitializeEx(NULL, 0);
1783
1784 getPathWithoutFinalSlashW(lDirname, aDefaultPathAndOrFile);
1785 getLastNameW(lBuff, aDefaultPathAndOrFile);
1786
1787 if (aNumOfFilterPatterns > 0)

Callers 1

openFileDialogWinGuiFunction · 0.85

Calls 2

getLastNameWFunction · 0.85

Tested by

no test coverage detected