ONE - On-device Neural Engine
Loading...
Searching...
No Matches
filesystem Namespace Reference

Functions

const std::string separator ()
 
std::string normalize_path (const std::string &path)
 Normalize compatible separator in path to default separator.
 
bool is_dir (const std::string &path)
 
bool mkdir (const std::string &path)
 
std::string join (const std::string &path1, const std::string &path2)
 
std::string basename (const std::string &path)
 

Function Documentation

◆ basename()

std::string filesystem::basename ( const std::string &  path)

Definition at line 29 of file filesystem_common.cpp.

30{
31 auto last_index = path.find_last_of(separator());
32
33 // No separator
34 if (last_index == std::string::npos)
35 return path;
36
37 // Trailing separator
38 if (last_index + separator().size() == path.size())
39 return basename(path.substr(0, last_index));
40
41 return path.substr(last_index + separator().size());
42}
const std::string separator()
std::string basename(const std::string &path)
int32_t size[5]
Definition Slice.cpp:35

References basename(), separator(), and size.

Referenced by basename().

◆ is_dir()

bool filesystem::is_dir ( const std::string &  path)

Definition at line 33 of file filesystem_linux.cpp.

34{
35 DIR *dir = opendir(path.c_str());
36 if (dir)
37 {
38 closedir(dir);
39 return true;
40 }
41 return false;
42}

◆ join()

std::string filesystem::join ( const std::string &  path1,
const std::string &  path2 
)

Definition at line 22 of file filesystem_common.cpp.

23{
24 // TODO check path1 does not end with separator
25 // TODO check path2 does not start with separator
26 return path1 + separator() + path2;
27}

References separator().

◆ mkdir()

bool filesystem::mkdir ( const std::string &  path)

Definition at line 44 of file filesystem_linux.cpp.

44{ return ::mkdir(path.c_str(), 0775) == 0; }

◆ normalize_path()

std::string filesystem::normalize_path ( const std::string &  path)

Normalize compatible separator in path to default separator.

Definition at line 27 of file filesystem_linux.cpp.

28{
29 // DO NOTHING
30 return path;
31}

◆ separator()

const std::string filesystem::separator ( )

Definition at line 25 of file filesystem_linux.cpp.

25{ return "/"; }

Referenced by basename(), and join().