[Plugin] [REL] FileManager 1.4 (24th of June 2012)
#1

What is FileManager?
FileManager is a simple plugin which allows you to manage files and folders.

Can't you just use the standard PAWN API?
Unlike the standard SA-MP API you are not limited to the scriptfiles server directory with this plugin.

Functions Included

pawn Code:
native file_move(file[],destination[]); // Moves a file
native file_delete(file[]); // Deletes a file
native file_create(file[]); // Creates a file
native file_write(file[],text[],mode[] = "a"); // Writes in append mode to a file, option to set write mode, append mode is default
native file_read(file[],storage[], sizeof(storage)); // Saves to the specified string
native file_log(); // Adding this will enable logging
native file_exists(file[]); // Check if a file exists

native File:f_open(file[], mode[] = "r"); // Opens a file for line-by-line reading. a for append, w for write, r for read.
native f_close(File:file); // Closes a file that was opened by f_open.
native f_read(File:file, storage, sizeof(storage)); // Reads from a file opened by f_open, line by line.
native f_write(File:file, string[]); // Writes to a file that has been opened by f_open

native dir_create(directory[]); // Creates a new directory
native dir_delete(directory[]); // Deletes a directory (Directory MUST be empty!)
native dir_exists(directory[]); // Check if a directory exists

native dir:dir_open(directory[]);
native dir_close(dir:handle);
native dir_list(dir:handle, storage[], &type, length = sizeof(storage));
Note: f_open is only needed for f_close and f_read, none of the file_ functions require f_open

Note: Similarly, dir_open is only need for dir_close and dir_list, it is not needed for the rest of the dir functions

Function Documentation

pawn Code:
/*
    Function: file_move(file[], destination[]);
    Description: Moves a specified file to the specified destination.
    Params:
            file[] - The name of the file to be moved.
            destination[] - The destination to move the file to, including the file name.
           
    Returns: True if success, false if not.


    Function: file_copy(file[], destination[]);
    Description: Copies a specified file to the specified destination.
    Params:
            file[] - The name of the file to be copied.
            destination[] - The new destination of the file to be copied to, including the file name.
           
    Returns: True if success, false if not.


    Function: file_delete(file[]);
    Description: Deletes a specified file.
    Params:
            file[] - The name of the file to be deleted.
           
    Returns: True if success, false if not.


    Function: file_create(file[]);
    Description: Creates a specified file.
    Params:
            file[] - The name of the file to be created.
           
    Returns: True if success, false if not.


    Function: file_write(file[], text[], mode[] = "a");
    Description: Writes a string to a specified file with the specified mode.
    Params:
            file[] - The name of the file to be written to.
            text[] - The string to write to the file.
            mode[] - The mode to use (doesn't need to be specified, will append by default, can be set otherwise)
           
    Returns: True if success, false if not.


    Function: file_read(file[], storage[], size = sizeof(storage));
    Description: Reads the entire file into a specified string.
    Params:
            file[] - The name of the file to be read into memory.
            storage[] - The array to store the read data in.
            size[] - The size of the storage array (used to prevent buffer overflows), no reason for you to specify it in practice.
           
    Returns: True if success, false if not.


    Function: file_log();
    Description: Will enable filemanager logging (prints information about file operations).


    Function: file_exists(file[]);
    Description: Checks if a specified file exists.
    Params:
            file[] - The name of the file to be checked for existence.
           
    Returns: True if success, false if not.


    Function: f_open(file[], mode[] = "r");
    Description: Opens a file for a reading operation.
    Params:
            file[] - The name of the file to be opened.
            mode[] (optional) - Specifies to mode to open the file in. "a" is append, "w" is write, "r" is read
           
    Returns: The file handle if success, else it returns false.


    Function: f_close(File: file);
    Description: Closes a file opened with f_open.
    Params:
            File:file - The handler of the file to be closed

    Returns: True if success, false if not.


    Function: f_read(File: file, storage[], size = sizeof(storage));
    Description: Reads from file that was opened by f_open line by line.
    Params:
            File:file - The handler of the file to be read from.
            storage[] - The string to store the read data from.
            size - This parameter does not need to be set by you.
           
    Returns: True if success, false if not.

    Function: f_write(File: file, string[]);
    Description: Writes to a file that has been opened with f_open
    Params:
            File:file - The handler of the file to be read from.
            string[] - The string to write to the file.
           
    Returns: True if success, false if not.


    Function: dir_create(directory[]);
    Description: Creates a directory.
    Params:
            directory[] - The path of the directory to be created.
           
    Returns: True if success, false if not.


    Function: dir_delete(directory[]);
    Description: Deletes a directory.
    Params:
            directory[] - The path of the directory to be deleted.
           
    Returns: True if success, false if not.


    Function: dir_exists(directory[]);
    Description: Checks if a directory exists
    Params:
            directory[] - The path of the directory to be deleted.
           
    Returns: 1 if it exists, 2 if it is a file and 0 if it does not exist.


    Function: dir:dir_open(directory[]);
    Description: Opens a directory
    Params:
            directory[] - The path of the directory to be opened.
           
    Returns: 1 if it exists, and 0 if it does not exist.


    Function: dir_close(dir:handle);
    Description: Closes a directory
    Params:
            dir:handle - The handle of the directory to close that was previously opened.
           
    Returns: Nothing.


    Function: dir_list(dir:handle, storage[], &type, length = sizeof(storage));
    Description: Reads through a directory, listing each file/sub-directory one by one.
    Params:
            dir:handle - The handle of the directory that is open to read from.
            storage[] - Where the name of the file/directory is stored.
            type - Where the type of directory is stored, can be either 1 or 2
            (optional) length - This is not needed unless you are passing an array without any length, in which case, use strlen with your array.
           
    Returns: 1 if there a sub-directory/file was found, 0 if there wasn't.
*/


// FM_DIR defines a directory and FM_FILE defines a file
// when using dir_list, these will be the types returned.
#define FM_DIR 1
#define FM_FILE 2
Quick Examples

Listing a directory

pawn Code:
new dir:dHandle = dir_open("./");
new item[40], type;
   
while(dir_list(dHandle, item, type))
{
    if(type == FM_FILE) printf("%s is a file", item);
    else if(type == FM_DIR) printf("%s is a directory", item);
}
       
dir_close(dHandle);
This will result in the contents of your SA-MP server directory being printed.

Supported Operating Systems
  • Windows
  • Linux
Download

Linux: https://github.com/JaTochNietDan/SA-..._1.5_Linux.zip
Windows: https://github.com/JaTochNietDan/SA-....5_Windows.zip

Source: https://github.com/JaTochNietDan/SA-MP-FileManager

Example Filterscript - https://github.com/JaTochNietDan/SA-...ter/sample.pwn

Each download comes with the required include file for PAWN.

Thanks to

G-sTyLeZzZ (Coding support)
****** (Bug finding)
Reply


Messages In This Thread
[REL] FileManager 1.4 (24th of June 2012) - by JaTochNietDan - 19.08.2009, 08:37
Re: [REL] FileManager - by saiberfun - 19.08.2009, 11:10
Re: [REL] FileManager - by Correlli - 19.08.2009, 11:27
Re: [REL] FileManager - by hansen111 - 19.08.2009, 11:51
Re: [REL] FileManager - by MatrixBoY - 19.08.2009, 13:28
Re: [REL] FileManager - by Amit_B - 19.08.2009, 15:56
Re: [REL] FileManager - by Adil - 19.08.2009, 16:37
Re: [REL] FileManager - by paytas - 19.08.2009, 17:34
Re: [REL] FileManager - by dugi - 19.08.2009, 18:22
Re: [REL] FileManager - by paytas - 19.08.2009, 18:28
Re: [REL] FileManager - by James_Alex - 19.08.2009, 19:16
Re: [REL] FileManager - by Donny_k - 19.08.2009, 21:17
Re: [REL] FileManager - by MenaceX^ - 20.08.2009, 07:34
Re: [REL] FileManager - by ruarai - 04.10.2009, 03:52
Re: [REL] FileManager - by mr.b - 04.10.2009, 04:18
Re: [REL] FileManager - by JaTochNietDan - 04.10.2009, 10:38
Re: [REL] FileManager - by CJ101 - 08.11.2009, 08:14
Re: [REL] FileManager - by ruarai - 13.11.2009, 22:18
Re: [REL] FileManager - by thegoliathmaster - 14.11.2009, 00:15
Re: [REL] FileManager - by JaTochNietDan - 14.11.2009, 17:30
Re: [REL] FileManager - by thegoliathmaster - 14.11.2009, 22:16
Re: [REL] FileManager - by JaTochNietDan - 14.11.2009, 22:52
Re: [REL] FileManager - by Kurence - 16.11.2009, 16:13
Re: [REL] FileManager - by Misiek - 16.11.2009, 18:49
Re: [REL] FileManager - by Kurence - 17.11.2009, 08:58
Re: [REL] FileManager - by JaTochNietDan - 17.11.2009, 17:13
Re: [REL] FileManager - by Kurence - 17.11.2009, 17:15
Re: [REL] FileManager - by cyber_punk - 17.11.2009, 17:39
Re: [REL] FileManager - by Kurence - 17.11.2009, 17:41
Re: [REL] FileManager - by JaTochNietDan - 17.11.2009, 18:21
Re: [REL] FileManager - by kukars22 - 25.11.2009, 12:45
Re: [REL] FileManager - by shindo - 26.12.2009, 12:23
Re: [REL] FileManager - by gijsmin - 26.12.2009, 15:32
REL FileManager - by brubsifiary - 29.12.2009, 22:32
Re: REL FileManager - by timmehhh - 29.12.2009, 22:42
Re: [REL] FileManager - by Calon - 11.01.2010, 16:09
Re: [REL] FileManager - by JaTochNietDan - 11.01.2010, 17:07
Re: [REL] FileManager - by Calgon - 12.01.2010, 09:56
Re: [REL] FileManager - by Mikep. - 21.01.2010, 21:28
Re: [REL] FileManager - by Calgon - 01.02.2010, 13:40
Re: [REL] FileManager - by JaTochNietDan - 01.02.2010, 16:44
Re: [REL] FileManager - by Deat_Itself - 11.02.2010, 13:39
Re: [REL] FileManager - by Franjdea - 01.03.2010, 17:11
Re: [REL] FileManager - by Bacovsky - 13.03.2010, 20:40
Re: [REL] FileManager - by Patrik356b - 19.03.2010, 15:08
Re: [REL] FileManager - by arnutisz - 26.03.2010, 22:44
Re: [REL] FileManager - by erorcun - 27.03.2010, 09:35
Re: AW: [REL] FileManager - by JaTochNietDan - 07.08.2010, 06:09
Re: [REL] FileManager - by Hiddos - 07.08.2010, 09:58
Re: [REL] FileManager - by RyDeR` - 17.08.2010, 17:42
Re: [REL] FileManager - by rbN. - 18.08.2010, 10:45
Re: [REL] FileManager - by RyDeR` - 18.08.2010, 22:07
Re: [REL] FileManager - by gamer931215 - 21.08.2010, 22:42
AW: [REL] FileManager - by Meta - 24.08.2010, 00:59
Re: [REL] FileManager - by JaTochNietDan - 24.08.2010, 06:03
AW: [REL] FileManager - by Meta - 24.08.2010, 12:15
Re: [REL] FileManager - by RyDeR` - 24.08.2010, 13:47
Re: [REL] FileManager 1.1 - by GBLTeam - 13.09.2010, 09:30
Re: [REL] FileManager 1.1 - by DiddyBop - 13.09.2010, 23:00
Re: [REL] FileManager 1.1 - by papagei9 - 18.09.2010, 19:44
AW: [REL] FileManager 1.1 - by Meta - 08.10.2010, 09:58
Re: [REL] FileManager 1.1 - by legodude - 19.10.2010, 15:07
Re: [REL] FileManager 1.1 - by JaTochNietDan - 19.10.2010, 16:01
Re: [REL] FileManager 1.1 - by legodude - 20.10.2010, 14:02
Re: [REL] FileManager 1.1 - by JaTochNietDan - 20.10.2010, 18:17
Re: [REL] FileManager 1.1 - by legodude - 22.10.2010, 15:14
Re: [REL] FileManager 1.1 - by Zeex - 22.10.2010, 17:17
Re: [REL] FileManager 1.1 - by F_Lexx - 23.10.2010, 21:27
Re: [REL] FileManager 1.1 - by legodude - 24.10.2010, 09:06
Re: [REL] FileManager 1.1 - by Diler - 07.01.2011, 14:09
Re: [REL] FileManager 1.1 - by Gamer_Z - 28.01.2011, 21:04
Re: [REL] FileManager 1.2 - by JaTochNietDan - 06.02.2011, 20:57
Re: [REL] FileManager 1.1 - by YmOn - 07.02.2011, 03:50
Re: [REL] FileManager 1.2 - by SkizzoTrick - 07.02.2011, 15:32
Re: [REL] FileManager 1.2 - by Mean - 10.02.2011, 15:36
Re: [REL] FileManager 1.2 - by [03]Garsino - 10.02.2011, 17:38
Re: [REL] FileManager 1.2 - by The_Moddler - 12.02.2011, 01:15
Re: [REL] FileManager 1.2 - by PinkFloydLover - 24.03.2011, 03:52
Re: [REL] FileManager 1.2 - by Rachael - 24.03.2011, 05:51
Re: [REL] FileManager 1.2 - by JaTochNietDan - 23.05.2011, 03:41
Re: [REL] FileManager 1.2 - by Ironboy - 23.05.2011, 04:49
AW: [REL] FileManager 1.2 - by Meta - 26.05.2011, 00:09
Re: [REL] FileManager 1.2 - by cs_master - 27.05.2011, 17:46
Re: [REL] FileManager 1.2 - by CJ101 - 27.05.2011, 19:52
Re: [REL] FileManager 1.2 - by TheGarfield - 27.05.2011, 21:46
AW: [REL] FileManager 1.2 - by Meta - 11.07.2011, 23:03
AW: [REL] FileManager 1.2 - by asdfgh98 - 16.07.2011, 18:53
Re: AW: [REL] FileManager 1.2 - by JaTochNietDan - 16.07.2011, 19:13
AW: [REL] FileManager 1.2 - by asdfgh98 - 17.07.2011, 01:50
Re: AW: [REL] FileManager 1.2 - by Calgon - 17.07.2011, 01:56
AW: [REL] FileManager 1.2 - by asdfgh98 - 17.07.2011, 01:57
Re: [REL] FileManager 1.2 - by Incubator - 17.07.2011, 12:43
Re: [REL] FileManager 1.2 - by Terminator3 - 17.07.2011, 13:57
Re: [REL] FileManager 1.2 - by Incubator - 17.07.2011, 15:02
AW: [REL] FileManager 1.2 - by Tion - 18.10.2011, 17:51
Re: [REL] FileManager 1.2 - by [WSF]ThA_Devil - 29.10.2011, 12:19
Re: [REL] FileManager 1.2 - by Scenario - 04.12.2011, 00:40
Re: [REL] FileManager 1.2 - by SVRP - 28.12.2011, 15:48
Re: [REL] FileManager 1.2 - by Tomer Amar - 28.12.2011, 15:59
Re: [REL] FileManager 1.2 - by kizla - 01.01.2012, 00:40
Re: [REL] FileManager 1.2 - by LZLo - 06.01.2012, 15:25
Re: [REL] FileManager 1.2 - by aGhillieSniper - 04.02.2012, 15:10
Re: [REL] FileManager 1.2 - by JaTochNietDan - 10.03.2012, 09:50
Re: [REL] FileManager 1.2 - by sam1929 - 13.03.2012, 06:33
Installing FileManager Plugin - by Dennis_Smith - 18.03.2012, 16:05
Re: Installing FileManager Plugin - by JaTochNietDan - 18.03.2012, 16:19
Re: [REL] FileManager 1.2 - by Dennis_Smith - 18.03.2012, 21:54
Re: [REL] FileManager 1.2 - by JaTochNietDan - 19.03.2012, 01:14
Re: [REL] FileManager 1.2 - by Dennis_Smith - 24.03.2012, 04:10
Re: [REL] FileManager 1.2 - by TheLazySloth - 29.03.2012, 19:35
Re: [REL] FileManager 1.3 - by JaTochNietDan - 09.05.2012, 16:05
Re : [REL] FileManager 1.3 (9th of May 2012) - by pseudonyme - 11.05.2012, 19:49
Re: [REL] FileManager 1.3 (9th of May 2012) - by Mandrakke - 15.06.2012, 13:41
Re: [REL] FileManager 1.3 (9th of May 2012) - by JaTochNietDan - 24.06.2012, 07:28
Re: [REL] FileManager 1.4 (24th of June 2012) - by Niko_boy - 24.06.2012, 08:02
AW: [REL] FileManager 1.4 (24th of June 2012) - by Meta - 02.07.2012, 22:32
Re: [REL] FileManager 1.4 (24th of June 2012) - by JaTochNietDan - 24.08.2012, 15:56
Re: [REL] FileManager 1.4 (24th of June 2012) - by -Stranger- - 29.09.2012, 19:56
Re: [REL] FileManager 1.4 (24th of June 2012) - by God'Z War - 29.09.2012, 21:06
Re: [REL] FileManager 1.4 (24th of June 2012) - by Emmet_ - 01.10.2012, 22:15
Re: [REL] FileManager 1.4 (24th of June 2012) - by admantis - 04.10.2012, 02:20
Re: [REL] FileManager 1.4 (24th of June 2012) - by Emmet_ - 04.10.2012, 03:11
Re: [REL] FileManager 1.4 (24th of June 2012) - by Pottus - 06.11.2012, 14:51
Re: [REL] FileManager 1.4 (24th of June 2012) - by newbienoob - 17.08.2013, 03:46
Re: [REL] FileManager 1.4 (24th of June 2012) - by Bit - 17.08.2013, 03:57
Re: [REL] FileManager 1.4 (24th of June 2012) - by newbienoob - 17.08.2013, 04:11
Re: [REL] FileManager 1.4 (24th of June 2012) - by Bit - 17.08.2013, 04:19
AW: [REL] FileManager 1.4 (24th of June 2012) - by BigETI - 17.08.2013, 08:12
Re: [REL] FileManager 1.4 (24th of June 2012) - by shaPP - 21.09.2013, 13:52
Re: [REL] FileManager 1.4 (24th of June 2012) - by QuaTTrO - 21.09.2013, 14:56
Re: [REL] FileManager 1.4 (24th of June 2012) - by shaPP - 21.09.2013, 14:58
Re: [REL] FileManager 1.4 (24th of June 2012) - by VIRUXE - 25.02.2014, 17:55
Re: [REL] FileManager 1.4 (24th of June 2012) - by RenovanZ - 08.03.2014, 14:37
Re: [REL] FileManager 1.4 (24th of June 2012) - by Battlezone - 08.03.2014, 14:44
Re : [REL] FileManager 1.4 (24th of June 2012) - by jojo62 - 27.03.2014, 17:07
Re: [REL] FileManager 1.4 (24th of June 2012) - by Tidzii - 02.06.2014, 15:59
Re: [REL] FileManager 1.4 (24th of June 2012) - by Slice - 31.07.2014, 17:48
Re: [REL] FileManager 1.4 (24th of June 2012) - by maddinat0r - 31.07.2014, 21:18
Re: [REL] FileManager 1.4 (24th of June 2012) - by nimagame - 14.08.2014, 16:58
Re: [REL] FileManager 1.4 (24th of June 2012) - by Mauzen - 14.08.2014, 17:02
Re: [REL] FileManager 1.4 (24th of June 2012) - by ZombieNest - 11.09.2014, 18:04
Re: [REL] FileManager 1.4 (24th of June 2012) - by Mark_Weston - 23.10.2014, 22:03
Re: [REL] FileManager 1.4 (24th of June 2012) - by Suxi - 15.05.2015, 10:40
Re: [REL] FileManager 1.4 (24th of June 2012) - by slipnkit - 26.04.2016, 08:06
Re: [REL] FileManager 1.4 (24th of June 2012) - by Crayder - 01.06.2016, 23:26
Re: [REL] FileManager 1.4 (24th of June 2012) - by elhanan - 06.07.2016, 08:30
Re: [REL] FileManager 1.4 (24th of June 2012) - by Silicium - 06.07.2016, 10:51
Re: AW: [REL] FileManager 1.2 - by mongi - 10.08.2017, 02:52
Re: AW: [REL] FileManager 1.2 - by JaTochNietDan - 10.08.2017, 10:36

Forum Jump:


Users browsing this thread: 2 Guest(s)