MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / Execute

Method Execute

Engine/source/platformWin32/nativeDialogs/fileDialog.cpp:316–502  ·  view source on GitHub ↗

Execute Method

Source from the content-addressed store, hash-verified

314// Execute Method
315//
316bool FileDialog::Execute()
317{
318 static char pszResult[MAX_PATH];
319#ifdef UNICODE
320 UTF16 pszFile[MAX_PATH];
321 UTF16 pszInitialDir[MAX_PATH];
322 UTF16 pszTitle[MAX_PATH];
323 UTF16 pszFilter[1024];
324 UTF16 pszFileTitle[MAX_PATH];
325 UTF16 pszDefaultExtension[MAX_PATH];
326 // Convert parameters to UTF16*'s
327 convertUTF8toUTF16((UTF8 *)mData.mDefaultFile, pszFile);
328 convertUTF8toUTF16((UTF8 *)mData.mDefaultPath, pszInitialDir);
329 convertUTF8toUTF16((UTF8 *)mData.mTitle, pszTitle);
330 convertUTF8toUTF16((UTF8 *)mData.mFilters, pszFilter);
331#else
332 // Not Unicode, All char*'s!
333 char pszFile[MAX_PATH];
334 char pszFilter[1024];
335 char pszFileTitle[MAX_PATH];
336 dStrcpy( pszFile, mData.mDefaultFile );
337 dStrcpy( pszFilter, mData.mFilters );
338 const char* pszInitialDir = mData.mDefaultPath;
339 const char* pszTitle = mData.mTitle;
340
341#endif
342
343 pszFileTitle[0] = 0;
344
345 // Convert Filters
346 U32 filterLen = dStrlen( pszFilter );
347 S32 dotIndex = -1;
348 for( U32 i = 0; i < filterLen; i++ )
349 {
350 if( pszFilter[i] == '|' )
351 pszFilter[i] = '\0';
352
353 if( pszFilter[ i ] == '.' && dotIndex == -1 )
354 dotIndex = i;
355 }
356 // Add second NULL terminator at the end
357 pszFilter[ filterLen + 1 ] = '\0';
358
359 // Get default extension.
360 dMemset( pszDefaultExtension, 0, sizeof( pszDefaultExtension ) );
361 if( dotIndex != -1 )
362 {
363 for( U32 i = 0; i < MAX_PATH; ++ i )
364 {
365 UTF16 ch = pszFilter[ dotIndex + 1 + i ];
366 if( !ch || ch == ';' || ch == '|' || dIsspace( ch ) )
367 break;
368
369 pszDefaultExtension[ i ] = ch;
370 }
371 }
372
373 OPENFILENAME ofn;

Callers 1

fileDialog.cppFile · 0.45

Calls 13

convertUTF8toUTF16Function · 0.85
dStrcpyFunction · 0.85
dIsspaceFunction · 0.85
getWin32WindowHandleFunction · 0.85
dStrncmpFunction · 0.85
convertUTF16toUTF8Function · 0.85
getIntArgFunction · 0.85
dStrlenFunction · 0.50
dMemsetFunction · 0.50
forwardslashFunction · 0.50
lookupMethod · 0.45

Tested by

no test coverage detected