Advertisement
RaFaeLs

## SA:MP RL_FILES v1.2.7 ##

Jan 31st, 2013
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.13 KB | None | 0 0
  1. /*
  2.  *                              rl_files 0.1.2
  3.  *        All right reserved! © By: RaFaeL
  4.  *
  5.  * Owner                : RaFaeL
  6.  * Time                 : 28.01.2013
  7.  *
  8.  * Thanks to:
  9.  *                      RaFaeL                           - Scripting, PAWN
  10.  *                      Kyosaur                          - How to build plugin
  11.  *                      SA:MP Team past, present, future - SA:MP.
  12.  *
  13.  *
  14.  * Functions:
  15.  *          fcheck(dir[], idx) - Check if file exist by idx
  16.  *          fnum(dir[]) - Return how much files in dir
  17.  *          fname(dir[], idx, souce[], len = sizeof(souce)) - Return the file name by idx
  18.  *          fprint(dir[]) - Print all files in dir
  19.  *          fend(file[], len = sizeof(file)) - Delete the file .(dot)
  20.  *
  21.  * CallBacks:
  22.  *          None.
  23.  *
  24.  * Update:
  25.  *      28.01.2013:
  26.  *          Other:              - First Release
  27.  *                              - Bug fixed
  28.  *      29.01.2013:
  29.  *          Functions:          - fend(file[], len = sizeof(file))
  30.  *                              -
  31.  *
  32.  *          Other:
  33.  *                              - fnum(dir[]) changed to PAWN scripted function
  34.  *                              - No meter if "." or "" directory
  35.  *      31.01.2013:
  36.  *          Other:              - Fixed bug while reading directorys
  37.  *                              - Default dir[] = "."
  38.  *
  39.  */
  40.  
  41. #if defined rl_files
  42.     #error files is already defined!
  43. #endif
  44. #define rl_files
  45.  
  46.  
  47. #define MAX_FILE_NAME    64
  48. #define NULL_DIR         "."
  49. #define PRINT_FORMAT "%s/%s",dir,file
  50.  
  51. native fname(dir[], idx, souce[], len = sizeof(souce));
  52.  
  53. stock fprint(dir[] = NULL_DIR) {
  54.     new
  55.         idx,
  56.         file[MAX_FILE_NAME];
  57.     while(fname(dir, idx, file)) {
  58.         printf(PRINT_FORMAT);
  59.         idx++;
  60.     }
  61.     return 1;
  62. }
  63.  
  64. stock fnum(dir[] = NULL_DIR) {
  65.     new
  66.         idx,
  67.         file[MAX_FILE_NAME];
  68.     while(fname(dir, idx, file)) {
  69.         idx++;
  70.     }
  71.     return idx;
  72. }
  73.  
  74. stock fcheck(dir[], idx) {
  75.     new
  76.         file[MAX_FILE_NAME];
  77.     if(!fname(dir, idx, file))
  78.         return 0;
  79.     return 1;
  80. }
  81.  
  82. stock fend(file[], len = sizeof(file)) {
  83.     new
  84.         ret[MAX_FILE_NAME];
  85.     strcat((ret[0] = EOS, ret), file);
  86.     strdel(ret, strfind(ret, ".", true), len);
  87.     return ret;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement