The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

DESCRIPTION

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.

FUNCTIONS

open

  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.

_open

  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.

close

  my $rv = close();

Closes the currently-open file.

read

  my $rv = read( $buffer, $size );

Reads $size bytes from the currently-opened file into $buffer. $size but be less-or-equal than 1024.

write

  my $rv = write( $buffer, $size );

Write $size bytes from the $buffer info the currently-opened file. $size but be less-or-equal than 1024.

seek

  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.

delete

  my $rv = delete( "/a/foo" );

Removes the given file.

searchRequest

  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.

fileList

  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.

dir

  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.

createDir

  my $rv = createDir( "/a/foodir" );

Creates the directory.

removeDir

  my $rv = removeDir( "/a/foodir" );

Removes the given directory. The directory must be empty.

getVolumeFreeSpace

  my $space = getVolumeFreeSpace( "/a" );

Returns the free space on the volume (in bytes).

SEE ALSO

Mobile::P2kMoto, Mobile::P2kMoto::FS::FileInfo