Advertisement
Lorenc

fremoveline & fupdateline - Created by Lorenc_

Feb 3rd, 2012
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.94 KB | None | 0 0
  1. stock fremoveline( filename[ ], line[ ] )
  2. {
  3.     if( fexist( filename ) )
  4.     {
  5.         new
  6.             szTmp[ 256 ],
  7.             File: fHandle = fopen( filename, io_read ),
  8.             File: fBullshit = fopen( "loltmp.ini", io_write )
  9.         ;
  10.         while( fread( fHandle, szTmp ) )
  11.         {
  12.             if( strfind( szTmp, line ) == -1 )
  13.             {
  14.                 fwrite( fBullshit, szTmp );
  15.             }
  16.         }
  17.         fclose( fHandle );
  18.         fclose( fBullshit );
  19.         fremove( filename );
  20.  
  21.         fHandle = fopen( filename, io_append );
  22.         fBullshit = fopen( "loltmp.ini", io_read );
  23.        
  24.         while( fread( fBullshit, szTmp ) ) {
  25.             fwrite( fHandle, szTmp );
  26.         }
  27.         fclose( fHandle );
  28.         fclose( fBullshit );
  29.         fremove( "loltmp.ini" );
  30.        
  31.         return 1;
  32.     }
  33.     return 0;
  34. }
  35.  
  36. stock fupdateline( filename[ ], szFind[ ], szReplace[ ] )
  37. {
  38.     if( fexist( filename ) )
  39.     {
  40.         new
  41.             szTmp[ 256 ],
  42.             File: fHandle = fopen( filename, io_read ),
  43.             File: fBullshit = fopen( "gibm8.ini", io_write )
  44.         ;
  45.        
  46.         while( fread( fHandle, szTmp ) )
  47.         {
  48.             if( strfind( szTmp, szFind ) != -1 )
  49.             {
  50.                 format( szTmp, sizeof( szTmp ), "%s\r\n", szReplace );
  51.                 fwrite( fBullshit, szTmp );
  52.                 continue;
  53.             }
  54.             else
  55.             {
  56.                 fwrite( fBullshit, szTmp );
  57.             }
  58.         }
  59.         fclose( fHandle );
  60.         fclose( fBullshit );
  61.         fremove( filename );
  62.  
  63.         fHandle = fopen( filename, io_write );
  64.         fBullshit = fopen( "gibm8.ini", io_read );
  65.        
  66.         while( fread( fBullshit, szTmp ) ) {
  67.             fwrite( fHandle, szTmp );
  68.         }
  69.        
  70.         fclose( fHandle );
  71.         fclose( fBullshit );
  72.         fremove( "gibm8.ini" );
  73.         return 1;
  74.     }
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement