Advertisement
garfield

[CODE]: Manipular arquivos sa-mp.

Nov 6th, 2012
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.38 KB | None | 0 0
  1. stock FileCopy(filename[60], newname[60]){
  2.  
  3.     if(!fexist(filename) || fexist(newname)){
  4.         return false;
  5.     }
  6.    
  7.     static
  8.         File: Arquivo,
  9.         Linhas[128],
  10.         Split[256]
  11.     ;
  12.    
  13.     Linhas[0]   = '\0';
  14.     Split[0]    = '\0';
  15.    
  16.     Arquivo = fopen(filename, io_read);
  17.     while(fread(Arquivo, Linhas)){
  18.         strcat(Split, Linhas);
  19.     }
  20.     fclose(Arquivo);
  21.  
  22.     Arquivo = fopen(newname, io_write);
  23.     fwrite(Arquivo, Split);
  24.     fclose(Arquivo);
  25.     return 1;
  26. }
  27.  
  28. stock FileRename(filename[], newname[]){
  29.  
  30.  
  31.     if(!fexist(filename) || fexist(newname)){
  32.         return false;
  33.     }
  34.    
  35.    
  36.     static
  37.         File: Arquivo,
  38.         Linhas[128],
  39.         Split[256]
  40.     ;
  41.  
  42.     Linhas[0]   = '\0';
  43.     Split[0]    = '\0';
  44.  
  45.     Arquivo = fopen(filename, io_read);
  46.     while(fread(Arquivo, Linhas)){
  47.         strcat(Split, Linhas);
  48.     }
  49.     fclose(Arquivo);
  50.  
  51.  
  52.     fremove(filename);
  53.    
  54.     Arquivo = fopen(newname, io_write);
  55.     fwrite(Arquivo, Split);
  56.     fclose(Arquivo);
  57.    
  58.     return true;
  59. }
  60. stock FileLineCount(filename[60])
  61. {
  62.     static
  63.         File:  Arquivo,
  64.         string[128],
  65.         Linhas
  66.     ;
  67.    
  68.     string[0]   = '\0';
  69.     Linhas      = 0;
  70.    
  71.     Arquivo = fopen(filename, io_read);
  72.    
  73.     while(fread(Arquivo, string)){
  74.         Linhas ++;
  75.     }
  76.    
  77.     return Linhas;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement