Folder Library



( ZN >= 0.0.1 )

Classes developed for easier management of directories.

 

# Methods


Bool create ( String $ file , Int $ permission = 0755 , Bool $ recursive = true )
Bool rename ( String $ oldName , String $ newName )
Bool copy ( String $ source , String $ target )
Bool change ( String $ name )
String basepath ()
Array fileInfo ( String $ dir , String $ extension = NULL )
float disk ( String $ dir , String $ type = 'free' )
Array files ( String $ path , $ extension = NULL , Boolean $ pathtyp to = false )
Array AllFiles ( string $ pattern = '*' , Boolean $ AllFiles = false )
Bool permission ( String $ name , Int $ permission = 0755 )
Bool deleteEmpty ( String $ folder )
Bool delete ( String $ name )

 

# Create ( ZN> = 0.0.1 )


Used to create an index.

Parameters

String $ path Directory path and name.
Int $ permission = 0755 Access authority.
Bool $ recursive = true Can create an index inside.
return Bool

uses

Folder::create('x/OrnekDizin', 0755);

 

# Rename ( ZN >= 0.0.1 )


Used to change directory name. 

Parameters

String $ path Directory path and name.
String $ NewName New name.
return Bool

uses

Folder::rename('Example/OldFolder', 'NewFolder');

 

# Copy ( ZN >= 0.0.1 )


Used to copy an index or a file from its current location to the desired location. This operation is applied to the files in the directory. That is, when the directory is copied, it is copied with the files and directories inside.

Parameters

String $ Source Source.
String $ target Target.
return Bool

uses

Folder::copy('Source/Example', 'Target/CopyExample');

 

# Change ( ZN >= 0.0.1 )


PHPis used to change the current working directory.

Parameters

String $ name Directory name.
return Bool

uses

echo getcwd();
Folder::change('xampp7/public_html');
echo getcwd();
xampp7 / htdocs / zeroneed
xampp7 / public_html

 

# BasePath ( ZN >= 4.0.3 )


Returns the active working directory information that the system is running.

Parameters

void
return String

uses

echo Folder::basePath();
xampp7 / htdocs / zeroneed 

 

# FileInfo ( ZN >= 3.0.0 )


Used to get information about the files of the specified directory.

Parameters

String $ Dirname Directory path and name.
String $ extension = NULL Which extensions files will be listed. The extension used for directories. For others, the use of the existing file extension is sufficient. If no parameters are specified, information about all files is listed.
Options dir and other file extensions
return Array

uses

output( Folder::fileInfo('Projects', 'php') );
Projects.php => array
(
        basename    => string 'Projects.php' (length = 14 ) ,
        you        => integer 4245 (length = 4 ) ,
        date        => integer 1471647303 (length = 10 ) ,
        readable    => boolean true ( length = 4 ) ,
        writable    => boolean true (length = 4 ) ,
        executable => boolean false (length = 5 ) ,
        permission => integer 33206 (length = 5 ) ,
)

We got the information of the files with the .php extension in the Projects / directory .

 

# Disc ( ZN >= 4.0.3 )


Used to get information about how much of the specified directory is available or what the total size is. byteReturns the numeric value in the method .

Parameters

String $ D Directory path and name.
String $ type = 'free' Kind.
free Returns the usable amount of the index.
the total Gets the total size of the index.
return Array

 

uses

\Output::writeLine( Folder::disk('Projects') . ' Bytes' );
\Output::writeLine( Folder::disk('Projects', 'total') . ' Bytes');
10090905600 Bytes
119926681600 Bytes 

 

# Files ( ZN> = 2.0.0 )


Used to retrieve a list of files belonging to the directory.

Parameters

String $ Dirname Directory path and name.
Mixed $ extension = NULL Which extensions files will be listed.
Bool $ isPath = false Are the files shown along with the road information?
return Array

uses

output( Folder::files('Projects/') );
0 => string '.htaccess' (length = 11 ) ,
1 => string 'Backend' (length = 9 ) ,
2 => string 'Frontend' (length = 10 ) ,
3 => string 'Projects.php' ( length = 14 )
output( Folder::files('Projects/', NULL, true) );
0 => string 'Projects / .htaccess' (length = 20 ) ,
1 => string 'Projects / Backend' (length = 18 ) ,
2 => string 'Projects / Frontend' (length = 19 ) ,
3 => string 'Projects / Projects.php' (length = 23 )
output( Folder::files('Projects/', 'php', true) );
0 => string 'Projects / Projects.php' (length = 23 )
output( Folder::files('Projects/', ['php', 'dir'], true) );
0 => string 'Projects / Projects.php' (length = 23 ) ,
1 => string 'Projects / Backend' (length = 18 ) ,
2 => string 'Projects / Frontend' (length = 19 )

 

# AllFiles ( ZN >= 2.0.0 )


Used to retrieve the list of files belonging to the directory together with the file paths. It differs from the files () method in that it does not distinguish between extensions, and that it can also scan in directories in the directory.

Parameters

String $ Dirname Directory path and name.
Bool $ isPath = false Are the files shown along with the road information?
return Array

uses

output( Folder::allFiles('Projects/') );
0 => string 'Projects / Backend' (length = 18 ) ,
1 => string 'Projects / Frontend' (length = 19 ) ,
2 => string 'Projects / Projects.php' (length = 23 )
output( Folder::allFiles('Projects/', true) );
0 => string 'Projects / backend / Controllers / Simplicity.php' (length = 45 ) ,
1 => string 'Projects / backend / Views / welcome.wizard.php' (length = 43 ) ,
2 => string 'Projects /frontend/config/classmap.php ' (length = 39 ) ,
3 => string ' Projects / Frontend / Config / cryptography.php ' (length = 43 ) ,
4 => string ' Projects / Frontend / Config / Database.php ' (length= 39 ) ,
5 => string 'Projects / Frontend / Config / encodingsupport.php' (length = 46 ) ,
6 => string 'Projects / Frontend / Config / filesystem.php' (length = 41 ) ,
7 => string 'Projects / Frontend / Config / General.php' (length = 38 ) ,
8 => string 'Projects / Frontend / Config / ındividualstructures.php' (length = 51 ) ,
9 => string 'Projects / frontend / config / Masterpage.php' (length = 41 ) ,
10 => string 'Projects / frontend / config / Project.php' (length = 38 ) ,
11 => string 'Projects / frontend / config / Services .php ' (length = 39 ) ,
12 => string ' Projects / Frontend / Config / Starting.php ' (length = 39 ) ,
13 => string ' Projects / Frontend / Config / viewobjects.php ' (length = 42 ),
14 => string 'Projects / Frontend / Controllers / Simplicity.php' (length = 46 ) ,
15 => string 'Projects / Frontend / Libraries / index.html (length = 40 ) ,
16 => string ' Projects / Frontend / Views / welcome.wizard.php ' (length = 44 ) ,
17 => string ' Projects / Projects.php ' (length = 23 )

Pattern Usage

If desired, you can type in the first parameter.

output( Folder::allFiles('Projects/*.php') );
0 => string 'Projects / Projects.php' (length = 23 )

 

# Permission ( ZN >= 0.0.1 )


Used to organize directory access permissions.

Parameters

String $ Dirname Directory path and name.
Int $ permission = 0755 Access authority.
return Bool

uses

Folder::permission('Example/', 0644);

 

# DeleteEmpty ( ZN> = 0.0.1 )


Used to delete empty directory.

Parameters

String $ Dirname Directory path and name.
return Bool

uses

Folder::deleteEmpty('Example/');

 

# Delete ( ZN> = 2.0.0 )


Used to delete the directory. Deletes the difference from the deleteEmpty () method with the files in the directory.

Parameters

String $ Dirname Directory path and name.
return Bool

uses

Folder::delete('Example/');