HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::ProjectDirectory Class Reference

#include <hal_core/utilities/project_directory.h>

Inheritance diagram for hal::ProjectDirectory:
Inheritance graph
Collaboration diagram for hal::ProjectDirectory:
Collaboration graph

Public Member Functions

 ProjectDirectory (const std::string &path=std::string())
 
std::filesystem::path get_default_filename (const std::string &extension=std::string()) const
 
std::filesystem::path get_filename (const std::string &relative_filename) const
 
std::filesystem::path get_shadow_filename (const std::string &extension=std::string()) const
 
std::filesystem::path get_shadow_dir () const
 
std::filesystem::path get_canonical_path () const
 
std::filesystem::path get_relative_file_path (const std::string &filename) const
 

Static Public Member Functions

static ProjectDirectory generate_random ()
 

Static Public Attributes

static const std::string s_shadow_dir = "autosave"
 

Friends

class ProjectManager
 

Detailed Description

Represents a project directory.

Definition at line 42 of file project_directory.h.

Constructor & Destructor Documentation

◆ ProjectDirectory()

hal::ProjectDirectory::ProjectDirectory ( const std::string &  path = std::string())

Constructs a ProjectDirectory object.

Parameters
[in]path- Path to the project directory. If the path has an extension (like .v or .hal) the extension will be removed.

Definition at line 9 of file project_directory.cpp.

Referenced by generate_random().

Member Function Documentation

◆ generate_random()

ProjectDirectory hal::ProjectDirectory::generate_random ( )
static

Generates a random directory name in the current working directory.

Returns
The absolute path to the generated directory.

Definition at line 15 of file project_directory.cpp.

References ProjectDirectory().

Referenced by hal::project_manager_init().

◆ get_canonical_path()

std::filesystem::path hal::ProjectDirectory::get_canonical_path ( ) const

Returns the canonical path to the project directory.

Returns
The absolute canonical path to the project directory. If no project path is given, an empty path is returned.

Definition at line 31 of file project_directory.cpp.

Referenced by get_default_filename(), get_filename(), get_relative_file_path(), get_shadow_dir(), hal::project_manager_init(), and hal::PythonSerializer::serialize_control().

◆ get_default_filename()

std::filesystem::path hal::ProjectDirectory::get_default_filename ( const std::string &  extension = std::string()) const

Returns the default file name for the project directory, which is a file with the same name as the project directory plus an extension.

Parameters
[in]extension- Extension of the default file name. If empty, .hal is assumed.
Returns
The absolute path to the default file.

Definition at line 38 of file project_directory.cpp.

References get_canonical_path(), and name.

Referenced by hal::ProjectManager::create_project_directory(), hal::FileManager::importFile(), hal::netlist_factory::load_netlist(), hal::FileManager::newProject(), hal::FileManager::openProject(), hal::project_manager_init(), and hal::ProjectManager::serialize_project().

◆ get_filename()

std::filesystem::path hal::ProjectDirectory::get_filename ( const std::string &  relative_filename) const

Returns the absolute path to a file within the project directory.

Parameters
[in]relative_filename- The relative file name within the project directory.
Returns
The absolute path to the file.

Definition at line 47 of file project_directory.cpp.

References get_canonical_path().

Referenced by hal::ProjectManager::create_project_directory(), hal::project_manager_init(), and hal::PythonSerializer::PythonSerializer().

◆ get_relative_file_path()

std::filesystem::path hal::ProjectDirectory::get_relative_file_path ( const std::string &  filename) const

Returns the relative file path if the file is within the project directory.

Parameters
[in]filename- The absolute path to the file.
Returns
The relative file path if the file is within the project directory; otherwise, the original filename.

Definition at line 74 of file project_directory.cpp.

References get_canonical_path().

Referenced by hal::project_manager_init(), hal::DotViewerFactory::serialize(), and hal::SimulatorSerializer::serialize().

◆ get_shadow_dir()

std::filesystem::path hal::ProjectDirectory::get_shadow_dir ( ) const

Returns the path to the autosave (shadow) directory.

Returns
The absolute path to the autosave directory.

Definition at line 67 of file project_directory.cpp.

References get_canonical_path(), and s_shadow_dir.

Referenced by hal::FileManager::autosave(), get_shadow_filename(), hal::FileManager::openProject(), and hal::project_manager_init().

◆ get_shadow_filename()

std::filesystem::path hal::ProjectDirectory::get_shadow_filename ( const std::string &  extension = std::string()) const

Returns the file name within the autosave (shadow) directory.

Parameters
[in]extension- Extension of the shadow file name. If empty, .hal is assumed.
Returns
The absolute path to the shadow file.

Definition at line 58 of file project_directory.cpp.

References get_shadow_dir(), and name.

Referenced by hal::project_manager_init(), and hal::ProjectManager::serialize_project().

Friends And Related Function Documentation

◆ ProjectManager

friend class ProjectManager
friend

Definition at line 44 of file project_directory.h.

Member Data Documentation

◆ s_shadow_dir

const std::string hal::ProjectDirectory::s_shadow_dir = "autosave"
static

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