GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Rex::FS::File(3) User Contributed Perl Documentation Rex::FS::File(3)

Rex::FS::File - File Class

This is the File Class used by file_write and file_read.

 use Rex::Interface::File;
 my $fh = Rex::Interface::File->create('Local');
 $fh->open( '<', 'filename' );

 my $file = Rex::FS::File->new(fh => $fh);
 $file->read($len);
 $file->read_all;
 $file->write($buf);
 $file->close;

This is the constructor. You need to set the filehandle which the object should work on or pass a filename. If you pass a filehandle, it has to be a "Rex::Interface::File::*" object

 my $fh = Rex::Interface::File->create('Local');
 $fh->open( '<', 'filename' );
 
 my $file = Rex::FS::File->new(fh => $fh);

Create a "Rex::FS::File" object with a filename

 # open a local file in read mode
 my $file = Rex::FS::File->new(
   filename => 'filename',
   mode     => 'r', # or '<'
   type     => 'Local',
 );
 
 # or shorter
 my $file = Rex::FS::File->new( filename => 'filename' );
 
 # open a local file in write mode
 my $file = Rex::FS::File->new(
   filename => 'filename',
   mode     => 'w', # or '>'
 );

Allowed modes:

 <  read
 r  read
 >  write
 w  write
 >> append
 a  append

For allowed "types" see documentation of Rex::Interface::File.

Write $buf into the filehandle.

 $file->write("Hello World");

Seek to the file position $offset.

Set the file pointer to the 5th byte.

 $file->seek(5);

Read $len bytes out of the filehandle.

 my $content = $file->read(1024);

Read everything out of the filehandle.

 my $content = $file->read_all;

Close the file.

 $file->close;
2021-07-05 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.