SA-MP Forums Archive
[Plugin] Directory 2.0 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] Directory 2.0 (/showthread.php?tid=309220)



Directory 2.0 - Terminator3 - 06.01.2012

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) Return false if directory doesn't exist


DirClose(DIR:dir)
closes open directory
Return true if directory has closed without any problems


DirRead(DIR:dir, name[])
Gets the name and type of element from directory
Return the element type*


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


DirCreate(const name[], mode = 420)
Creates a directory Returns true if the directory is correctly created


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


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


DirRemove(const name[], bool:empty = false)
Removes a directory and all subfolders and files inside
Return 'true' if directory has been successfully removed


Chmod(const patch[], mode)
Sets the chmod of a directory/file
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);



AW: Directory 2.0 - Meta - 06.01.2012

Looks good
I'll try it!

EDIT:
Quote:
Originally Posted by Terminator3
Посмотреть сообщение
DirCreate(const name[])
Rename(const oldname[], const newname[])
From older plugin, that's a functions from C, mkdir and rename, (return == 0)
Little mistake?


Respuesta: Directory 2.0 - Jovanny - 06.01.2012

Good job, its useful


Respuesta: Directory 2.0 - [Nikk] - 06.01.2012

Looks very nice men, i will try this


Re: Directory 2.0 - steki. - 06.01.2012

Looks nice.


Re: Directory 2.0 - TheArcher - 06.01.2012

It could be useful if this detect how many files are in the directory, what format is that file in the directory and such.


Re: Directory 2.0 - Babul - 07.01.2012

hohoho! this plugin surely takes away some pain of scripting with .catalogue files, its really handy, thank you!
one question: do you intent to let the DirRead() output its content sorted? i could need that for easier browsing through numbered files :O)


Re: Directory 2.0 - [O.z]Caroline - 07.01.2012

Very nice!


Re: Directory 2.0 - Terminator3 - 07.01.2012

Quote:
Originally Posted by Babul
Посмотреть сообщение
hohoho! this plugin surely takes away some pain of scripting with .catalogue files, its really handy, thank you!
one question: do you intent to let the DirRead() output its content sorted? i could need that for easier browsing through numbered files :O)
DirRead (readdir from dirent.h) has already sorts files by name, just is some small difference on linux

EDIT:
small update


Re: Directory 2.0 - GangsTa_ - 07.01.2012

That's nice, might be useful for some things.


Re: Directory 2.0 - BrandyPenguin - 24.01.2012

Any mirror? I can't download from solidfiles.com


Re: Directory 2.0 - Terminator3 - 24.01.2012

Ok, all files:
http://adf.ly/5SSH6


Re: Directory 2.0 - papedo - 27.02.2013

Bug report:
{
Chmod in DirCreate didnґt work. Please fix it in next release

if I use:
pawn Код:
DirCreate("Logs/Test",502);
Chmod is 744

But it is fixable by:
pawn Код:
Chmod("Logs/Test",502);
Chmod is OK = 766
}


Re: Directory 2.0 - Terminator3 - 12.11.2013

Quote:
Originally Posted by papedo
Посмотреть сообщение
Bug report:
{
Chmod in DirCreate didnґt work. Please fix it in next release

if I use:
pawn Код:
DirCreate("Logs/Test",502);
Chmod is 744

But it is fixable by:
pawn Код:
Chmod("Logs/Test",502);
Chmod is OK = 766
}
Oh sorry, for that late response and this bug, i don't know how i missed it, it easy to fix, in source should be

Код:
return (!mkdir(name, params[2]));
instead of
Код:
return (!mkdir(name, S_IREAD | S_IWRITE | S_IRGRP | S_IROTH)); // permission 0644
i don't have linux right now so i can't fix it


Re: Directory 2.0 - Fancy - 05.08.2015

The links are not working


Re: Directory 2.0 - Dayvison_ - 05.08.2015

Quote:
Originally Posted by Fancy
Посмотреть сообщение
The links are not working
All links on in http://pawno.pl/index.php?/topic/723...derami-w-samp/


Re: Directory 2.0 - maxisaibot - 04.01.2018

This plugin dead? Any alternative plugin for Centos7 ?


Re: Directory 2.0 - Sew_Sumi - 04.01.2018

Quote:
Originally Posted by maxisaibot
Посмотреть сообщение
This plugin dead? Any alternative plugin for Centos7 ?
CentOS is the most tricky distro to use, simply use Ubuntu... Its a lot easier, and you won't spend weeks trying to find support.