
Mobile::P2kMoto::FS - filesystem access for Motorola P2K phones

Functions for listing,
creating,
reading files and directories.
All the functions must be called only after a succesful call to openPhone().
IMPORTANT: only one file can be open at a given time.

my $fh = open( "/a/foo", 0, $size );
Opens or creates a file, returning a Perl filehandle. Only one file can be opened at the same time. Make sure you always call close() before calling open() again.
Due to the poor interface offered by the p2kmoto library, when opening a file for reading or updating, the starting size of the file must be specified. This might be fixed in the future.
my $rv = _open( "/a/foo", 0 );
Opens or creates a file. Note that since only one file can be opened at the same time, the return value is a status, not a file handle. Make sure you always call close() before calling open() again.
This maps directly to the p2k_FSAC_open() function.
Use open() unless you know you need this function.
my $rv = close();
Closes the currently-open file.
my $rv = read( $buffer, $size );
Reads $size bytes from the currently-opened file into $buffer. $size but be less-or-equal than 1024.
my $rv = write( $buffer, $size );
Write $size bytes from the $buffer info the currently-opened file. $size but be less-or-equal than 1024.
my $rv = seek( $offset, $whence );
Seeks on the currently-open file. $whence can be one of P2K_SEEK_BEGIN, P2K_SEEK_CURRENT, P2K_SEEK_END. $size but be less-or-equal than 1024.
my $rv = delete( "/a/foo" );
Removes the given file.
my $count = searchRequest( "/a/*.mp3" );
Performs a search in the filesystem. The results can be read using fileList(). Note that the search is always recursive. Returns the number of files matching the request.
Valid patterns are *.foo and /c/*.foo.
my $callback = sub { print $_[0]->name };
my $rv = fileList( $callback );
Calls $callback for every file in the file list. If searchRequest() was not called, lists every file, otherwise only the ones matched by the last searchRequest(). The first and only argument to the callback is a Mobile::P2kMoto::FS::FileInfo object.
my @fileinfo = dir( "/a/*.mp3" );
Internally does a call to searchRequest and fileList and returns a list of Mobile::P2kMoto::FS::FileInfo as result. Will try to handle patterns more complicated than those supported by plain searchRequest.
my $rv = createDir( "/a/foodir" );
Creates the directory.
my $rv = removeDir( "/a/foodir" );
Removes the given directory. The directory must be empty.
my $space = getVolumeFreeSpace( "/a" );
Returns the free space on the volume (in bytes).
