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

Function saveFileDialogWinConsole

lib/tinyfiledialogs/tinyfiledialogs.cpp:2651–2712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2649
2650
2651static char * saveFileDialogWinConsole(
2652 char * aoBuff ,
2653 char const * aTitle , /* NULL or "" */
2654 char const * aDefaultPathAndOrFile ) /* NULL or "" */
2655{
2656 char lDialogString[MAX_PATH_OR_CMD];
2657 char lPathAndFile[MAX_PATH_OR_CMD] = "";
2658 FILE * lIn;
2659
2660 strcpy( lDialogString , "dialog " ) ;
2661 if ( aTitle && strlen(aTitle) )
2662 {
2663 strcat(lDialogString, "--title \"") ;
2664 strcat(lDialogString, aTitle) ;
2665 strcat(lDialogString, "\" ") ;
2666 }
2667
2668 strcat(lDialogString, "--backtitle \"") ;
2669 strcat(lDialogString,
2670 "tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
2671 strcat(lDialogString, "\" ") ;
2672
2673 strcat( lDialogString , "--fselect \"" ) ;
2674 if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
2675 {
2676 /* dialog.exe uses unix separators even on windows */
2677 strcpy(lPathAndFile, aDefaultPathAndOrFile);
2678 replaceChr( lPathAndFile , '\\' , '/' ) ;
2679 }
2680
2681 /* dialog.exe needs at least one separator */
2682 if ( ! strchr(lPathAndFile, '/') )
2683 {
2684 strcat(lDialogString, "./") ;
2685 }
2686 strcat(lDialogString, lPathAndFile) ;
2687 strcat(lDialogString, "\" 0 60 2>");
2688 strcpy(lPathAndFile, getenv("TEMP"));
2689 strcat(lPathAndFile, "\\tinyfd.txt");
2690 strcat(lDialogString, lPathAndFile);
2691
2692 /* printf( "lDialogString: %s\n" , lDialogString ) ; */
2693 system( lDialogString ) ;
2694
2695 if (!(lIn = fopen(lPathAndFile, "r")))
2696 {
2697 remove(lPathAndFile);
2698 return NULL;
2699 }
2700 while (fgets(aoBuff, MAX_PATH_OR_CMD, lIn) != NULL)
2701 {}
2702 fclose(lIn);
2703 remove(lPathAndFile);
2704 replaceChr( aoBuff , '/' , '\\' ) ;
2705 /* printf( "aoBuff: %s\n" , aoBuff ) ; */
2706 getLastName(lDialogString,aoBuff);
2707 if ( ! strlen(lDialogString) )
2708 {

Callers 1

tinyfd_saveFileDialogFunction · 0.85

Calls 2

replaceChrFunction · 0.85
getLastNameFunction · 0.85

Tested by

no test coverage detected