[Plugin] Directory 2.0
#1

This is a continuation and refinement rather my previous plugin with that name klik

Functions:

DIR: DirOpen(const dirname[])
opens the directory to read it (You can open up to 32 folders at the same time)
  • const dirname[] - name of a directory
Return false if directory doesn't exist


DirClose(DIR:dir)
closes open directory
  • DIR:dir - id of a directory returned by DirOpen
Return true if directory has closed without any problems


DirRead(DIR:dir, name[])
Gets the name and type of element from directory
  • DIR:dir - id of a directory returned by DirOpen
  • name[] - return name of element
Return the element type*


DirRewind(DIR:dir)
Function moves a place to start reading a folder
  • DIR:dir - id of a directory returned by DirOpen
Returns true if the id of a directory is correct


DirCreate(const name[], mode = 420)
Creates a directory
  • const name[] - name of a directory
  • mode - chmod, unused on Windows
Returns true if the directory is correctly created


Rename(const oldname[], const newname[])
Renames a file / directory or move it to another location
  • const oldname[] - old name of a file/directory or the old localization
  • const newname[] - new name of a file/directory or the new localization
Returns true if the operation is performed correctly


CheckPath(const patch[])
Checks the type of element
  • const patch[] - name of file/directory
Returns the element type (directory, file)*


DirRemove(const name[], bool:empty = false)
Removes a directory and all subfolders and files inside
  • const name[] - name of a directory
  • bool:empty = false - if you know the directory is empty set this to true
Return 'true' if directory has been successfully removed


Chmod(const patch[], mode)
Sets the chmod of a directory/file
  • const patch[] - name of element
  • mode - mode, e.g. S_IREAD | S_IWRITE | S_IRGRP | S_IROTH or IntToOctal(644)
Windows
Linux
(names are the same in my dir.inc)

*Types of element (definitions):
type_unknown - not found or unknown type
type_dir - directory
type_file - file
type_other - other type

if you want to use chmod on Windows and you script gonna work only on Windows paste
pawn Код:
#define WIN32
//or
#define WIN
above
pawn Код:
#include <dir>
DOWNLOAD:
Windows .dll
Linus .so (on Ubuntu 11.04)
Includ .inc

and

soucre code

Mirror:
Direct download (all files)

Example:
pawn Код:
new str[100],
    type,
    DIR:xxx = DirOpen("."); // scriptfiles

if(!xxx)
    return print("directory not found");

type = DirRead(xxx, str);
while(str[0])
{
    printf("\'%s\' type: %d", str, type);
    type = DirRead(xxx, str);
}
DirClose(xxx);
Reply


Messages In This Thread
Directory 2.0 - by Terminator3 - 06.01.2012, 20:42
AW: Directory 2.0 - by Meta - 06.01.2012, 20:49
Respuesta: Directory 2.0 - by Jovanny - 06.01.2012, 20:51
Respuesta: Directory 2.0 - by [Nikk] - 06.01.2012, 20:51
Re: Directory 2.0 - by steki. - 06.01.2012, 20:54
Re: Directory 2.0 - by TheArcher - 06.01.2012, 21:33
Re: Directory 2.0 - by Babul - 07.01.2012, 03:29
Re: Directory 2.0 - by [O.z]Caroline - 07.01.2012, 03:43
Re: Directory 2.0 - by Terminator3 - 07.01.2012, 08:42
Re: Directory 2.0 - by GangsTa_ - 07.01.2012, 10:55
Re: Directory 2.0 - by BrandyPenguin - 24.01.2012, 10:34
Re: Directory 2.0 - by Terminator3 - 24.01.2012, 16:52
Re: Directory 2.0 - by papedo - 27.02.2013, 14:29
Re: Directory 2.0 - by Terminator3 - 12.11.2013, 16:14
Re: Directory 2.0 - by Fancy - 05.08.2015, 09:07
Re: Directory 2.0 - by Dayvison_ - 05.08.2015, 14:27
Re: Directory 2.0 - by maxisaibot - 04.01.2018, 18:34
Re: Directory 2.0 - by Sew_Sumi - 04.01.2018, 21:09

Forum Jump:


Users browsing this thread: 2 Guest(s)