tbx  0.7.5
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
tbx::PathInfo Class Reference

Class to hold the catalogue information for a file. More...

#include <path.h>

Classes

class  Iterator
 Iterator used to iterate through a directory. More...
 

Public Types

enum  ObjectType { NOT_FOUND, FILE, DIRECTORY, IMAGE_FILE }
 
enum  Attribute {
  OWNER_READ = 0x1, OWNER_WRITE = 0x2, OWNER_LOCKED = 0x8, OTHER_READ = 0x10,
  OTHER_WRITE = 0x20, OTHER_LOCKED = 0x80
}
 

Public Member Functions

 PathInfo ()
 Construct and empty PathInfo not referring to any file.
 
 PathInfo (const PathInfo &other)
 Copy constructor. More...
 
PathInfooperator= (const PathInfo &other)
 Assign to the value of another PathInfo. More...
 
bool operator== (const PathInfo &other)
 Checks if this path info is identical to another. More...
 
bool operator!= (const PathInfo &other)
 Checks if this path info is different to another. More...
 
bool read (const Path &path)
 Read catalogue information for the given path. More...
 
bool read_raw (const Path &path, bool calc_file_type)
 Read catalogue information for the given path always returning the raw load/exec address. More...
 
const std::string & name () const
 Get the leaf name of the object the information if for. More...
 
ObjectType object_type () const
 Return the object type read for this path. More...
 
bool exists () const
 
bool file () const
 
bool directory () const
 
bool image_file () const
 
bool has_file_type () const
 Check if this path info has file type information. More...
 
int file_type () const
 Get the file type of the object. More...
 
int raw_file_type () const
 Return the file type from the load/exec address. More...
 
UTCTime modified_time () const
 Return the modification time of the file if it has it. More...
 
bool has_load_address () const
 Check if path info has a load address and executable address. More...
 
unsigned int load_address () const
 Get the load address for this PathInfo. More...
 
unsigned int exec_address () const
 Get the executable address for this PathInfo. More...
 
int length () const
 Get the length of this object on the file system. More...
 
int attributes () const
 Return the objects file attributes. More...
 

Static Public Member Functions

static PathInfo::Iterator begin (const Path &path, const std::string &wildCard)
 Returns an iterator for the given path that will return the PathInfo information for each object matched. More...
 
static PathInfo::Iterator begin (const Path &path)
 Returns an iterator for the given path that will return the PathInfo information for all objects in the directory. More...
 
static PathInfo::Iterator end ()
 Get iterator for checking end of iteration of a path. More...
 

Protected Attributes

std::string _name
 
ObjectType _object_type
 
unsigned int _load_address
 
unsigned int _exec_address
 
int _length
 
int _attributes
 
int _file_type
 

Friends

class Iterator::IterBlock
 

Detailed Description

Class to hold the catalogue information for a file.

Member Enumeration Documentation

◆ Attribute

Attributes of an object. 0 or more of these will be combined using the | operation.

Enumerator
OWNER_WRITE 

Read access for owner

OWNER_LOCKED 

Write access for owner

OTHER_READ 

Object locked against owner deletion

OTHER_WRITE 

Read access for others

OTHER_LOCKED 

Write access for others

◆ ObjectType

Type of an object

Enumerator
NOT_FOUND 

Path does not exist on disc

FILE 

Path is a file

DIRECTORY 

Path is a directory

IMAGE_FILE 

Path is an image file

Constructor & Destructor Documentation

◆ PathInfo()

PathInfo::PathInfo ( const PathInfo other)

Copy constructor.

Parameters
otherPathInfo to copy

Member Function Documentation

◆ attributes()

int PathInfo::attributes ( ) const

Return the objects file attributes.

The lower byte of the attributes are 0 or more of the values in the PathInfo::Attribute enum ored together.

Returns
file attributes of the object

◆ begin() [1/2]

PathInfo::Iterator PathInfo::begin ( const Path path,
const std::string &  wildCard 
)
static

Returns an iterator for the given path that will return the PathInfo information for each object matched.

Parameters
pathdirectory to iterate
wildCardwild carded string for iteration
Returns
iterator

◆ begin() [2/2]

PathInfo::Iterator PathInfo::begin ( const Path path)
static

Returns an iterator for the given path that will return the PathInfo information for all objects in the directory.

Parameters
pathdirectory to iterate
Returns
iterator

◆ directory()

bool tbx::PathInfo::directory ( ) const
inline

Returns true if object is a directory on the file system

◆ end()

PathInfo::Iterator PathInfo::end ( )
static

Get iterator for checking end of iteration of a path.

Returns
end of directory iterator

◆ exec_address()

unsigned int PathInfo::exec_address ( ) const

Get the executable address for this PathInfo.

This value only refers to a real executable address if has_load_address is true

Returns
executable address for this object

◆ exists()

bool tbx::PathInfo::exists ( ) const
inline

Returns true if object exists on the file system

◆ file()

bool tbx::PathInfo::file ( ) const
inline

Returns true if object is a file on the file system

◆ file_type()

int PathInfo::file_type ( ) const

Get the file type of the object.

Returns
The file type of the object or -2 if invalid object -1 if the object doesn't have a file type 0x1000 if the object is a directory 0x2000 if the object is an application directory

◆ has_file_type()

bool PathInfo::has_file_type ( ) const

Check if this path info has file type information.

Returns
true if the object has a file type

◆ has_load_address()

bool PathInfo::has_load_address ( ) const

Check if path info has a load address and executable address.

Returns
true if this object has a load address

◆ image_file()

bool tbx::PathInfo::image_file ( ) const
inline

Returns true if object is am image file on the file system

◆ length()

int PathInfo::length ( ) const

Get the length of this object on the file system.

Returns
the object length in number of bytes

◆ load_address()

unsigned int PathInfo::load_address ( ) const

Get the load address for this PathInfo.

This value only refers to a real load address if has_load_address is true

Returns
load address of this object

◆ modified_time()

UTCTime PathInfo::modified_time ( ) const

Return the modification time of the file if it has it.

Returns
modified time or UTCTime()

◆ name()

const std::string& tbx::PathInfo::name ( ) const
inline

Get the leaf name of the object the information if for.

Returns
leaf name of the object

◆ object_type()

PathInfo::ObjectType PathInfo::object_type ( ) const

Return the object type read for this path.

Returns
object type

◆ operator!=()

bool PathInfo::operator!= ( const PathInfo other)

Checks if this path info is different to another.

Note: name check is case-sensitive

Parameters
otherPathInfo to check
Returns
true if PathInfos are different

◆ operator=()

PathInfo & PathInfo::operator= ( const PathInfo other)

Assign to the value of another PathInfo.

Parameters
otherPathInfo to copy
Returns
*this

◆ operator==()

bool PathInfo::operator== ( const PathInfo other)

Checks if this path info is identical to another.

Note: name check is case-sensitive

Parameters
otherPathInfo to check
Returns
true if PathInfos are the same

◆ raw_file_type()

int PathInfo::raw_file_type ( ) const

Return the file type from the load/exec address.

For image FS files it will return the actual file type of the image file whereas file_type returns 0x1000 (directory).

The return value is undefined for directories/applications or files that do not have file types.

The file_type() must be -1 or the PathInfo read with the read_raw functions for this to give the correct results.

Returns
raw file type.

◆ read()

bool PathInfo::read ( const Path path)

Read catalogue information for the given path.

Parameters
pathPath referring to a location on a file system
Returns
true if information read

◆ read_raw()

bool PathInfo::read_raw ( const Path path,
bool  calc_file_type 
)

Read catalogue information for the given path always returning the raw load/exec address.

This can be used to get the actual file type for an ImageFS directory.

Parameters
pathPath referring to a location on a file system
calc_file_typetrue to calculate file type from the returned catalogue information, if false file_type -1 will always be returned.
Returns
true if information read

Member Data Documentation

◆ _attributes

int tbx::PathInfo::_attributes
protected

object attributes

◆ _exec_address

unsigned int tbx::PathInfo::_exec_address
protected

Executable address

◆ _file_type

int tbx::PathInfo::_file_type
protected

object file type

◆ _length

int tbx::PathInfo::_length
protected

Length of object

◆ _load_address

unsigned int tbx::PathInfo::_load_address
protected

Load address

◆ _name

std::string tbx::PathInfo::_name
protected

Name of the file system object

◆ _object_type

ObjectType tbx::PathInfo::_object_type
protected

Object type


The documentation for this class was generated from the following files: