Advertisement
TerusTheBird

masker: die_piss_logs.c

Jan 7th, 2025
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | Source Code | 0 0
  1. #ifndef __shittydialog_c
  2. #define __shittydialog_c
  3.  
  4. #include "die_piss_logs.h"
  5.  
  6. static void strip_end( char* str, int str_len ) {
  7.     int i;
  8.     for( i = 0; i < str_len; ++i ) {
  9.         if( str[ i ] == '\n' ) str[ i ] = '\0';
  10.     }
  11. }
  12.  
  13. // kdialog load file
  14. int dialog_load( char* title, char* out_path, int out_path_len ) {
  15.     char temp[ 8192 ];
  16.     FILE* pipe;
  17.     memset( temp, 0, 8192 );
  18.     memset( out_path, 0, out_path_len );
  19.     if( !title ) title = "Load file";
  20.     snprintf( temp, 8191, "kdialog --getopenfilename --title '%s'", title );
  21.     pipe = popen( temp, "r" );
  22.     if( !pipe ) return 0;
  23.     fgets( out_path, out_path_len-1, pipe );
  24.     pclose( pipe ); pipe = NULL;
  25.     strip_end( out_path, out_path_len );
  26.     return 1;
  27. }
  28.  
  29. // kdialog save file
  30. int dialog_save( char* title, char* out_path, int out_path_len ) {
  31.     char temp[ 8192 ];
  32.     FILE* pipe;
  33.     memset( temp, 0, 8192 );
  34.     memset( out_path, 0, out_path_len );
  35.     if( !title ) title = "Load file";
  36.     snprintf( temp, 8191, "kdialog --getsavefilename --title '%s'", title );
  37.     pipe = popen( temp, "r" );
  38.     if( !pipe ) return 0;
  39.     fgets( out_path, out_path_len-1, pipe );
  40.     pclose( pipe ); pipe = NULL;
  41.     strip_end( out_path, out_path_len );
  42.     return 1;
  43. }
  44.  
  45.  
  46.  
  47. #endif
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement