ELC in dev
ELC-lang
载入中...
搜索中...
未找到
elc::paths::defs 命名空间参考

函数

bool file_exists (const string &name) noexcept
 
string get_program_data_path () noexcept
 
string get_system_drive () noexcept
 
string get_elc_runtime_lib_path () noexcept
 

函数说明

◆ file_exists()

bool elc::paths::defs::file_exists ( const string &  name)
inlinenoexcept

在文件 all_defs.cpp55522 行定义.

55522 {
55523 #if SYSTEM_TYPE == windows
55524 return GetFileAttributesA(to_char_str(name).c_str())!=INVALID_FILE_ATTRIBUTES;
55525 #elif SYSTEM_TYPE == linux
55526 return access(to_char_str(name).c_str(),F_OK)==0;
55527 #else
55528 auto fp = ::std::fopen(to_char_str(name).c_str(), "rb");
55529 if(fp){
55530 ::std::fclose(fp);
55531 return true;
55532 }
55533 return false;
55534 #endif
55535 }
函数调用图:
这是这个函数的调用关系图:

◆ get_elc_runtime_lib_path()

string elc::paths::defs::get_elc_runtime_lib_path ( )
inlinenoexcept

在文件 all_defs.cpp55560 行定义.

55560 {
55561 #if SYSTEM_TYPE == windows
55562 //windows: if can read file ProgramData/elc/flag , use ProgramData/elc
55563 //else try to read SystemDrive/elc/flag , use ProgramData/elc
55564 //else return "./elc"
55565 {
55566 string program_data_path=get_program_data_path();
55567 if(program_data_path.size() && file_exists(program_data_path + es"/elc/flag"_constexpr_str))
55568 return program_data_path+es"/elc"_constexpr_str;
55569 }
55570 {
55571 string system_drive=get_system_drive();
55572 if(system_drive.size() && file_exists(system_drive + es"/elc/flag"_constexpr_str))
55573 return system_drive+es"/elc"_constexpr_str;
55574 }
55575 #elif SYSTEM_TYPE == linux
55576 //linux: if can read file /usr/lib/elc/flag , use /usr/lib/elc
55577 //else return "./elc"
55578 string flag_path=es"/usr/lib/elc/flag"_constexpr_str;
55579 if(file_exists(flag_path))
55580 return es"/usr/lib/elc"_constexpr_str;
55581 #endif
55582 return es"./elc"_constexpr_str;
55583 }
#define es
Definition all_defs.cpp:680
bool file_exists(const string &name) noexcept
string get_program_data_path() noexcept
函数调用图:
这是这个函数的调用关系图:

◆ get_program_data_path()

string elc::paths::defs::get_program_data_path ( )
inlinenoexcept

在文件 all_defs.cpp55536 行定义.

55536 {
55537 #if SYSTEM_TYPE == windows
55538 char path[MAX_PATH];
55539 if(!SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_COMMON_APPDATA, NULL, 0, path)))
55540 return string{};
55541 return to_char_t_str(path);
55542 #elif SYSTEM_TYPE == linux
55543 return es"/usr/local/share"_constexpr_str;
55544 #else
55545 return string{};
55546 #endif
55547 }
函数调用图:
这是这个函数的调用关系图:

◆ get_system_drive()

string elc::paths::defs::get_system_drive ( )
inlinenoexcept

在文件 all_defs.cpp55548 行定义.

55548 {
55549 #if SYSTEM_TYPE == windows
55550 char path[MAX_PATH];
55551 if(!SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_WINDOWS, NULL, 0, path)))
55552 return string{};
55553 return to_char_t_str(path)+es"\\.."_constexpr_str;
55554 #elif SYSTEM_TYPE == linux
55555 return es"/"_constexpr_str;
55556 #else
55557 return string{};
55558 #endif
55559 }
函数调用图:
这是这个函数的调用关系图: