Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef __shittydialog_c
- #define __shittydialog_c
- #include "die_piss_logs.h"
- static void strip_end( char* str, int str_len ) {
- int i;
- for( i = 0; i < str_len; ++i ) {
- if( str[ i ] == '\n' ) str[ i ] = '\0';
- }
- }
- // kdialog load file
- int dialog_load( char* title, char* out_path, int out_path_len ) {
- char temp[ 8192 ];
- FILE* pipe;
- memset( temp, 0, 8192 );
- memset( out_path, 0, out_path_len );
- if( !title ) title = "Load file";
- snprintf( temp, 8191, "kdialog --getopenfilename --title '%s'", title );
- pipe = popen( temp, "r" );
- if( !pipe ) return 0;
- fgets( out_path, out_path_len-1, pipe );
- pclose( pipe ); pipe = NULL;
- strip_end( out_path, out_path_len );
- return 1;
- }
- // kdialog save file
- int dialog_save( char* title, char* out_path, int out_path_len ) {
- char temp[ 8192 ];
- FILE* pipe;
- memset( temp, 0, 8192 );
- memset( out_path, 0, out_path_len );
- if( !title ) title = "Load file";
- snprintf( temp, 8191, "kdialog --getsavefilename --title '%s'", title );
- pipe = popen( temp, "r" );
- if( !pipe ) return 0;
- fgets( out_path, out_path_len-1, pipe );
- pclose( pipe ); pipe = NULL;
- strip_end( out_path, out_path_len );
- return 1;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement