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

Function openFileDialogWinConsole

lib/tinyfiledialogs/tinyfiledialogs.cpp:2715–2772  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2713
2714
2715static char * openFileDialogWinConsole(
2716 char const * aTitle , /* NULL or "" */
2717 char const * aDefaultPathAndOrFile ) /* NULL or "" */
2718{
2719 char lFilterPatterns[MAX_PATH_OR_CMD] = "";
2720 char lDialogString[MAX_PATH_OR_CMD] ;
2721 FILE * lIn;
2722
2723 static char aoBuff[MAX_PATH_OR_CMD];
2724
2725 strcpy( lDialogString , "dialog " ) ;
2726 if ( aTitle && strlen(aTitle) )
2727 {
2728 strcat(lDialogString, "--title \"") ;
2729 strcat(lDialogString, aTitle) ;
2730 strcat(lDialogString, "\" ") ;
2731 }
2732
2733 strcat(lDialogString, "--backtitle \"") ;
2734 strcat(lDialogString,
2735 "tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
2736 strcat(lDialogString, "\" ") ;
2737
2738 strcat( lDialogString , "--fselect \"" ) ;
2739 if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
2740 {
2741 /* dialog.exe uses unix separators even on windows */
2742 strcpy(lFilterPatterns, aDefaultPathAndOrFile);
2743 replaceChr( lFilterPatterns , '\\' , '/' ) ;
2744 }
2745
2746 /* dialog.exe needs at least one separator */
2747 if ( ! strchr(lFilterPatterns, '/') )
2748 {
2749 strcat(lDialogString, "./") ;
2750 }
2751 strcat(lDialogString, lFilterPatterns) ;
2752 strcat(lDialogString, "\" 0 60 2>");
2753 strcpy(lFilterPatterns, getenv("TEMP"));
2754 strcat(lFilterPatterns, "\\tinyfd.txt");
2755 strcat(lDialogString, lFilterPatterns);
2756
2757 /* printf( "lDialogString: %s\n" , lDialogString ) ; */
2758 system( lDialogString ) ;
2759
2760 if (!(lIn = fopen(lFilterPatterns, "r")))
2761 {
2762 remove(lFilterPatterns);
2763 return NULL;
2764 }
2765 while (fgets(aoBuff, MAX_PATH_OR_CMD, lIn) != NULL)
2766 {}
2767 fclose(lIn);
2768 remove(lFilterPatterns);
2769 replaceChr( aoBuff , '/' , '\\' ) ;
2770 /* printf( "aoBuff: %s\n" , aoBuff ) ; */
2771 return aoBuff;
2772}

Callers 1

tinyfd_openFileDialogFunction · 0.85

Calls 1

replaceChrFunction · 0.85

Tested by

no test coverage detected