class::fs::Dir

class fs::Dir
  : public api::FsWorkObject

Todo: Add some examples

Summary

Dir()

~Dir()

int close()

int count()

char * data()

DIR * dirp()

bool get_entry(

var::String & path_dest
)

var::String get_entry()

int ino()

bool is_open() const

const char * name()

int open(

const arg::SourceDirectoryPath & name
)

const char * read()

var::Vector< var::String > read_list()

void rewind()

void seek(

arg::Location location
)

long tell()

static int copy(

const arg::SourceDirectoryPath source_path,
const arg::DestinationDirectoryPath destination_path
)

static int create(

const arg::DestinationDirectoryPath & path,
const Permissions & permissions
)

static int create(

const arg::DestinationDirectoryPath & path,
const Permissions & permissions,
const arg::IsRecursive is_recursive
)

static bool exists(

const arg::SourceDirectoryPath & path
)

static var::Vector< var::String > read_list(

const arg::SourceDirectoryPath & path
)

static int remove(

const arg::SourceDirectoryPath path,
const arg::IsRecursive recursive
)

Members

Dir()

Constructs a Dir object.


~Dir()

Destructs the object.

If the object has a directory that is currently open, the directory will be closed upon destruction.


int close()

Closes the directory.

If this method is not called explicitly before the object is destroyed, it will be called during destruction. See ~Dir().


int count()

Counts the total number of entries in the directory.


char * data()

Returns a pointer (editable) to the name of the most recently read entry.


DIR * dirp()

Returns the directory handle pointer.


bool get_entry(

var::String & path_dest
)

Gets the next entry and writes the full path of the entry to the given string.

Parameters

  • path_dest The var::String that will hold the full path of the next entry.

Returns

True if an entry was read or false for an error or no more entries


var::String get_entry()

int ino()

Returns the serial number of the most recently read entry.


bool is_open() const

Returns true if the directory is open.


const char * name()

Returns a pointer (const) to the name of the most recently read entry.


int open(

const arg::SourceDirectoryPath & name
)

Opens a directory.


const char * read()

Returns a pointer to the next entry or 0 if no more entries exist.


var::Vector< var::String > read_list()

Returns a list of all the entries in the directory.

#include <sapi/fs.hpp>
#include <sapi/var.hpp>

Dir d;

d.open(arg::SourceDirectoryPath("/home");
Vector<String> list = d.read_list();
d.close();

for(u32 i=0; i < list.count(); i++){
  printf("Entry is %s\n", list.at(i).cstring());
}

void rewind()

Rewinds the directory pointer.


void seek(

arg::Location location
)

Seeks to a location in the directory.

Each entry in the directory occupies 1 location space. The first entry is at location 0.


long tell()

Returns the current location in the directory.


static int copy(

const arg::SourceDirectoryPath source_path,
const arg::DestinationDirectoryPath destination_path
)


static int create(

const arg::DestinationDirectoryPath & path,
const Permissions & permissions
)

Returns true if the directory exists.


static int create(

const arg::DestinationDirectoryPath & path,
const Permissions & permissions,
const arg::IsRecursive is_recursive
)


static bool exists(

const arg::SourceDirectoryPath & path
)

Returns true if the directory exists.


static var::Vector< var::String > read_list(

const arg::SourceDirectoryPath & path
)


static int remove(

const arg::SourceDirectoryPath path,
const arg::IsRecursive recursive
)

Removes a directory.

Returns

Zero on success or -1 for an error


X

Thanks for Coming!

Subscribe to news and updates