File Library



( ZN >= 0.0.1 )

It is the library created for files operations.

 

# Methods


String read ( String $ file )
String contents ( String $ file )
Object find ( String $ file , String $ data )
Bool create ( String $ name )
Int write ( String $ file , String $ data )
Int append ( String $ file , String $ data )
String replace ( String $ name , Mixed $ data , Mixed $ replace )
Mixed truncate ( String $ file , Int $ limit = 0 , String $ mode = 'r +' )
Bool delete ( String $ name )
Bool rename ( String $ oldName , String $ newName )
Bool permission ( String $ file , Int $ permission = 0755 )
Object info ( String $ file )
float size ( String $ file , String $ type = 'b' , Int $ decimal = 2 )
String createDate ( String $ file , String $ type = 'dmY G: i: s' )
String changeDate ( String $ file , String $ type = 'dmY G: i: s' )
Int owner ( String $ file )
Int group ( String $ file )
void CleanCache ( string $ filename = null , boolean $ real = false )
Int rowCount ( String $ file = '/' , Bool $ recursive = true )
Bool createZip ( String $ path , Array $ data )
Bool zipExtract ( String $ source , String $ target = NULL )  
void download ( String $ file )

 

# Read /Contents ( ZN >= 0.0.1 )


Used to read files.

Parameters

String $ file File path.
return String

uses

File::read('example.txt');

 

# Find ( ZN >= 1.0.6 )


Used to search the file.

Parameters

String $ file File path.
String $ data Data.
return Object index Position of the search for the bald.
contents The contents of the file.

uses

$data = File::find('example.txt', 'example');
\Output::writeLine('Index:{0}, Contents:{1}', [$data->index, $data->contents]);
Index: 1 , Contents: example-data

 

# Create ( ZN> = 0.0.1 )


Used to create files. If there is a file with the same name as the file to be created, the creation will fail.

Parameters

String $ file File path.
return Bool

uses

File::create('example.txt');

 

# Write ( ZN >= 0.0.1 )


yenidenUsed to print data to a file . However, if there is already data in the file, the data will be erased and rewritten.

Parameters

String $ file File path.
String $ data Data.
return Int

uses

File::write('example.txt', 'abc');
echo File::read('example.txt');
a B C
File::write('example.txt', 'xxx');
echo File::read('example.txt'); 
xxx

 

# Append ( ZN >= 0.0.1 )


devamınaUsed to print the data of the file .

Parameters

String $ file File path.
String $ data Data.
return Int

uses

File::append('example.txt', 'abc');
echo File::read('example.txt');
a B C
File::append('example.txt', 'xxx');
echo File::read('example.txt'); 
abcxxx

 

# Replace ( ZN >= 4.0.3 )


Used to change the data in the file.

Parameters

String $ file File path.
String $ data The data to be changed.
String $ Replace New data.
return String

uses

echo File::replace('example.txt', 'xxx', 'yyy');
abcyyy

 

# Truncate ( ZN >= 4.0.3 ) / Limit ( ZN & lt; = 4.0.22 )


Put a file on a certain length.

Parameters

String $ file File path.
Int $ limit = 0 Limit amount.
String $ mode = 'r +' Mod.
return void

uses

\Output::writeLine(File::read('example.text'));
File::truncate('example.txt', 2);
\Output::writeLine(File::read('example.txt'));
abcd
ab

 

# Delete ( ZN> = 0.0.1 )


Used to delete files.

Parameters

String $ file File path.
return Bool

uses

File::delete('example.txt');

 

# Rename ( ZN >= 0.0.1 )


Used to change the file name.

Parameters

String $ file File path.
String $ NewName My new job.
return Bool

uses

File::rename('example.txt', 'new_example.txt');

 

# Permission ( ZN >= 0.0.1 )


Used to organize file permissions.

Parameters

String $ file File path.
Int $ permission = 0755 Authority.
return Bool

uses

File::permission('example.txt', 0600);

 

# Info ( ZN >= 2.0.5 )


Returns information about the object that contains some information about the file.

Parameters

String $ file File path.
return Object basename File name.
to you File size.
date File creation date.
readable File readability.
writable The writability of the file.
executable Executable of the file.
the permission The authority of the file.

uses

output( File::info('robots.txt') );
basename    => string 'robots.txt' (length = 12 )
size        => integer 79 (length = 2 )
date        => integer 1471293018 (length = 10 )
readable    => boolean true (length = 4 )
writable    => boolean true ( length = 4 )
executable => boolean false (length = 5 )
permission => integer 33206 (length = 5 )

 

# Size ( ZN >= 2.0.0 )


Used to get information about file size.

Parameters

String $ file File path.
String $ type = 'b' Output type.
Int $ decimal = 2 The number of decimal digits.
return float

uses

\Output::writeLine( File::size('zeroneed.php') );
\Output::writeLine( File::size('zeroneed.php', 'mb', 1) );
\Output::writeLine( File::size('zeroneed.php', 'mb', 2) );
7241
0
0.01 

 

# CreateDate ( ZN> = 2.0.0 )


Gives the file creation date information.

Parameters

String $ file File path.
String $ type = 'dmY G: i: s' Display type.
return String

uses

echo File::createDate('robots.txt');
15.08.2016 5:21:24 

 

# ChangeDate ( ZN> = 2.0.0 )


Gives the date the file was modified.

Parameters

String $ file File path.
String $ type = 'dmY G: i: s' Display type.
return String

uses

echo File::changeDate('robots.txt');
15.08.2016 22:30:18  

 

# Owner ( ZN >= 2.0.3 )


Gives the file owner.

Parameters

String $ file File path.
return Mixed

uses

echo File::owner('robots.txt');
0

 

# Group ( ZN >= 2.0.3 )


It gives the group that owns the file.

Parameters

String $ file File path.
return Mixed

uses

echo File::group('robots.txt');
0

 

# CleanCache ( ZN> = 3.0.0 )


Deletes the file status cache.

Parameters

String $ file File path.
Bool $ realPath = false Real road.
return Mixed

uses

File::cleanCache();

 

# RowCount ( ZN >= 3.0.2 )


Returns the number of lines of code in the file. It can calculate the number of lines in all the files in a single file or in a directory.

Parameters

String $ file File path.
Bool $ recursive = false Scan inside.
return Mixed

uses

\Output::writeLine( File::rowCount('example.txt') );
\Output::writeLine( File::rowCount('Example/') );
\Output::writeLine( File::rowCount('Example/', true) );
1
5887
11774 

 

# CreateZip ( ZN >= 3.0.3 )


Used to create a ZIP file. With the 2nd parameter, it is determined which files will be zigzagged.

Parameters

String $ path Zip file path.
Array $ data Files to be included in the compression.
return Bool

uses

File::createZip('example.zip', ['example.txt', 'Example/']);

 

# ZipExtract ( ZN >= 1.0.6 )


Used to extract files contained in a zip file.

Parameters

String $ Source Zip file path.
String $ target Directory to extract.
return Bool

uses

File::zipExtract('example.zip', 'ExampleZip/');

 

# Download ( ZN >= 0.0.1 )


Starts a file download.

Parameters

String $ file File path.
return void

uses

File::download('xx/xa/file.png');