remove launchd entry on unmount
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
@@ -368,6 +368,7 @@ auto generate_launchd_plist(const plist_cfg &cfg, bool overwrite_existing)
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_PUGIXML)
|
||||
|
||||
#if defined(PROJECT_ENABLE_FMT)
|
||||
auto launchctl_command(std::string_view label, launchctl_type type) -> int {
|
||||
switch (type) {
|
||||
case launchctl_type::bootout:
|
||||
@@ -398,6 +399,25 @@ auto launchctl_command(std::string_view label, launchctl_type type) -> int {
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto remove_launchd_plist(std::string_view plist_path, std::string_view label,
|
||||
bool should_bootout) -> bool {
|
||||
auto file = utils::file::file{
|
||||
utils::path::combine(plist_path, {label + ".plist"}),
|
||||
};
|
||||
if (not file.exists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto res =
|
||||
should_bootout ? launchctl_command(label, launchctl_type::bootout) : 0;
|
||||
if (not file.remove()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return res == 0;
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_FMT)
|
||||
#endif // defined(__APPLE__)
|
||||
} // namespace repertory::utils
|
||||
|
||||
|
Reference in New Issue
Block a user