mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
add makeUniqueName for saveas
This commit is contained in:
parent
6d69ba1e1f
commit
da73f5ea9b
1 changed files with 20 additions and 1 deletions
|
@ -1002,6 +1002,25 @@ isDefaultName( XP_UCHAR* name )
|
||||||
return 0 == XP_STRCMP( UNSAVEDGAMEFILENAME, name, );
|
return 0 == XP_STRCMP( UNSAVEDGAMEFILENAME, name, );
|
||||||
} /* isDefaultName */
|
} /* isDefaultName */
|
||||||
|
|
||||||
|
static void
|
||||||
|
makeUniqueName( wchar_t* buf, XP_U16 bufLen )
|
||||||
|
{
|
||||||
|
XP_U16 i;
|
||||||
|
DWORD attributes;
|
||||||
|
|
||||||
|
for ( i = 1; i < 100; ++i ) {
|
||||||
|
swprintf( buf, DEFAULT_DIR_NAME L"\\Untitled%d.xwg", i );
|
||||||
|
XP_ASSERT( wcslen(buf) < bufLen );
|
||||||
|
|
||||||
|
attributes = GetFileAttributes( buf );
|
||||||
|
if ( attributes == 0xFFFFFFFF ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* If we fall out of the loop, the user will be asked to confirm delete
|
||||||
|
of Untitled99 or somesuch. That's ok.... */
|
||||||
|
} /* makeUniqueName */
|
||||||
|
|
||||||
static XP_Bool
|
static XP_Bool
|
||||||
ceSaveCurGame( CEAppGlobals* globals, XP_Bool autoSave )
|
ceSaveCurGame( CEAppGlobals* globals, XP_Bool autoSave )
|
||||||
{
|
{
|
||||||
|
@ -1029,7 +1048,7 @@ ceSaveCurGame( CEAppGlobals* globals, XP_Bool autoSave )
|
||||||
XP_MEMSET( &sfs, 0, sizeof(sfs) );
|
XP_MEMSET( &sfs, 0, sizeof(sfs) );
|
||||||
XP_MEMSET( nameBuf, 0, sizeof(nameBuf) );
|
XP_MEMSET( nameBuf, 0, sizeof(nameBuf) );
|
||||||
|
|
||||||
wcscpy( nameBuf, DEFAULT_DIR_NAME L"\\Untitled.xwg" );
|
makeUniqueName( nameBuf, sizeof(nameBuf)/sizeof(nameBuf[0]) );
|
||||||
|
|
||||||
sfs.lStructSize = sizeof(sfs);
|
sfs.lStructSize = sizeof(sfs);
|
||||||
sfs.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
|
sfs.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
|
||||||
|
|
Loading…
Add table
Reference in a new issue