Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Directory

Add this in your code:

#include <engine/file_system/directory.h>

Description

Class to manage a directory (Get all files of a folder).

Variables


NameTypeDescription
subdirectoriesstd::vector<std::shared_ptr<Directory>>List of sub directories (filled with GetAllFiles)
filesstd::vector<std::shared_ptr<File>>List of files (filled with GetAllFiles)

Public methods


GetAllFiles

Get all the files of the directory (can be very slow and not currently supported on PS3).

Parameters:

  • recursive: If true, get all the files of the subdirectories
std::vector<std::shared_ptr<File>> GetAllFiles(bool recursive)

Code sample:

std::shared_ptr<Directory> directory = FileSystem::MakeDirectory("C:/my_folder/");

std::vector<std::shared_ptr<File>> files = directory->GetAllFiles(true);

CheckIfExist

Check if the directory exists.

bool CheckIfExist() const

Code sample:

std::shared_ptr<Directory> directory = FileSystem::MakeDirectory("C:/my_folder/");

bool directoryExists = directory->CheckIfExist();

GetPath

Get directory path.

const std::string& GetPath() const

Code sample:

std::shared_ptr<Directory> directory = FileSystem::MakeDirectory("C:/my_folder/");

const std::string& path = directory->GetPath(); // = "C:/my_folder/"