Overview   Project   Class   Tree   Index 
NXT C++ Bluetooth Library
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

NXT C++ Bluetooth Library
Class Filesystem

   in filesystem.h
   in filesystem.cpp

class Filesystem

Class to interact with the filesystem on the NXT


Constructor Summary
private  Filesystem( const Filesystem& p )
          To prevent copy - to lazy to create a copy constructor
  Filesystem( Connection* connection )
          
  ~Filesystem()
          
 
Method Summary
 void close_file( Nxt_file& file )
          close a file on the nxt
 unsigned int create_file_list( string wild_card )
          Create a file list
 void delete_file( string file_name, bool reply = false )
          Delete a file on the NXT
 void delete_file( Nxt_file& file, bool reply = false )
          Delete a file on the NXT
 void delete_flash()
          Delete the flash memory - all user programs and data
 void download_file( string pc_name, string nxt_name )
          Download a file from the NXT to the PC
 Nxt_file get_file_list_element( unsigned int idx )
          Get a element from the file list
 unsigned int get_file_list_size()
          Get the number of files in the file list
 unsigned int get_free_flash()
          Get remaining flash memory
 Nxt_file open_file( string file_name, File_mode mode, unsigned int file_size = 0 )
          Open or create a file on the NXT
 unsigned int read_file( Nxt_file& file, unsigned char* buffer, unsigned int num_bytes )
          read a byte string from a file
 void upload_file( string pc_name, string nxt_name )
          Upload a file from the PC to the NXT
 unsigned int write_file( Nxt_file& file, unsigned char* buffer, unsigned int num_bytes )
          write a byte string to a file
 

Constructor Detail

Filesystem

private Filesystem( const Filesystem& p );
To prevent copy - to lazy to create a copy constructor

Filesystem

public Filesystem( Connection* connection );
Parameters:
*connection - [attach a connection]

~Filesystem

public ~Filesystem();


Method Detail

close_file

public void close_file( Nxt_file& file );
close a file on the nxt
Parameters:
&file - [Nxt_file struct of the file to close]

create_file_list

public unsigned int create_file_list( string wild_card );
Create a file list
Parameters:
wild_card - [search cretia]
  • filename.extension (search for a specific file )
  • *.[file name type] (search for file type)
  • filename.* (search for files with a specific filename)
  • *.* (list all files)
Returns:
number of files in the file list

delete_file

public void delete_file( string file_name, bool reply = false );
Delete a file on the NXT
Parameters:
file_name - [the name of the file to delete]
reply - [true = require reply from NXT; false = no reply from NXT]

delete_file

public void delete_file( Nxt_file& file, bool reply = false );
Delete a file on the NXT
Parameters:
file - [a Nxt_file struct of the file to close]
reply - [true = require reply from NXT; false = no reply from NXT]

delete_flash

public void delete_flash();
Delete the flash memory - all user programs and data

download_file

public void download_file( string pc_name, string nxt_name );
Download a file from the NXT to the PC
Parameters:
pc_name - [path to the download destination (example: c:\\download.txt)]
nxt_name - [name of the file on the NXT (example: "program.rxe")]

get_file_list_element

public Nxt_file get_file_list_element( unsigned int idx );
Get a element from the file list
Parameters:
idx - [the element to return ( 0= first element in the list)]
Returns:
a nxt file struct (if idx is out of range all attributes in the struct will be zero - use the file list size to make sure you are not out of range)

get_file_list_size

public unsigned int get_file_list_size();
Get the number of files in the file list
Returns:
number of files in the file list

get_free_flash

public unsigned int get_free_flash();
Get remaining flash memory
Returns:
the remaining flash memory in bytes

open_file

public Nxt_file open_file( string file_name, File_mode mode, unsigned int file_size = 0 );
Open or create a file on the NXT
Parameters:
file_name - [the name of the file to create or open]
mode - [use the FILE_MODE enumeration how the file should be created or opended]
file_size - [the size of the file in bytes (will be ignored in append and read mode)]
Returns:
a nxt file struct containing the data of the openend file

read_file

public unsigned int read_file( Nxt_file& file, unsigned char* buffer, unsigned int num_bytes );
read a byte string from a file
Parameters:
&file - [Nxt_file struct of the file to read data from]
*buffer - [a pointer to a buffer that can hold the read bytes]
no_bytes - [bytes to read]
Returns:
number of bytes that was read

upload_file

public void upload_file( string pc_name, string nxt_name );
Upload a file from the PC to the NXT
Parameters:
pc_name - [path to the PC file to upload (example: c:\\upload.txt)]
nxt_name - [name of the file on the NXT (example: "data.txt")]

write_file

public unsigned int write_file( Nxt_file& file, unsigned char* buffer, unsigned int num_bytes );
write a byte string to a file
Parameters:
&file - [Nxt_file struct of the file to write data to]
*buffer - [a pointer to a buffer that can hold the bytes to write]
no_bytes - [bytes to write]
Returns:
number of bytes that was written

 Overview   Project   Class   Tree   Index 
NXT C++ Bluetooth Library
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD