mirror of
https://github.com/reactos/reactos.git
synced 2025-05-07 10:46:58 +00:00

The code of the single GPL-2.0 only file "misc.c" was originally derived from GPL-2.0 only devmgmt. I have now replaced it with the same code from LGPL-2.1+ mmc, which makes my application a full GPL-2.0+ work. This is legit, because I know that Thomas Weidenmueller is the original author of the "misc.c" code. svn path=/trunk/; revision=75987
76 lines
1.6 KiB
C
76 lines
1.6 KiB
C
/*
|
|
* PROJECT: ReactOS VGA Font Editor
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
|
* PURPOSE: Functions for opening and saving files
|
|
* COPYRIGHT: Copyright 2008 Colin Finck (colin@reactos.org)
|
|
*/
|
|
|
|
#include "precomp.h"
|
|
|
|
static OPENFILENAMEW ofn;
|
|
|
|
VOID
|
|
FileInitialize(IN HWND hwnd)
|
|
{
|
|
ZeroMemory( &ofn, sizeof(ofn) );
|
|
ofn.lStructSize = sizeof(ofn);
|
|
ofn.hwndOwner = hwnd;
|
|
ofn.nMaxFile = MAX_PATH;
|
|
ofn.lpstrDefExt = L"bin";
|
|
}
|
|
|
|
static __inline VOID
|
|
PrepareFilter(IN PWSTR pszFilter)
|
|
{
|
|
// RC strings can't be double-null terminated, so we use | instead to separate the entries.
|
|
// Convert them back to null characters here.
|
|
do
|
|
{
|
|
if(*pszFilter == '|')
|
|
*pszFilter = 0;
|
|
}
|
|
while(*++pszFilter);
|
|
}
|
|
|
|
BOOL
|
|
DoOpenFile(OUT PWSTR pszFileName)
|
|
{
|
|
BOOL bRet;
|
|
PWSTR pszFilter;
|
|
|
|
if( AllocAndLoadString(&pszFilter, IDS_OPENFILTER) )
|
|
{
|
|
PrepareFilter(pszFilter);
|
|
ofn.lpstrFilter = pszFilter;
|
|
ofn.lpstrFile = pszFileName;
|
|
ofn.Flags = OFN_FILEMUSTEXIST;
|
|
|
|
bRet = GetOpenFileNameW(&ofn);
|
|
HeapFree(hProcessHeap, 0, pszFilter);
|
|
|
|
return bRet;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL
|
|
DoSaveFile(IN OUT PWSTR pszFileName)
|
|
{
|
|
BOOL bRet;
|
|
PWSTR pszFilter;
|
|
|
|
if( AllocAndLoadString(&pszFilter, IDS_SAVEFILTER) )
|
|
{
|
|
PrepareFilter(pszFilter);
|
|
ofn.lpstrFilter = pszFilter;
|
|
ofn.lpstrFile = pszFileName;
|
|
|
|
bRet = GetSaveFileNameW(&ofn);
|
|
HeapFree(hProcessHeap, 0, pszFilter);
|
|
|
|
return bRet;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|