utilities to set and get process title now available
This commit is contained in:
parent
17c01f1c7e
commit
add2153b8f
@ -584,6 +584,31 @@ struct Utilities {
|
||||
return avg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the title of the current process.
|
||||
* @return The process title.
|
||||
*/
|
||||
static std::string processTitle() {
|
||||
std::size_t size = details::DEFAULT_SIZE;
|
||||
char buf[details::DEFAULT_SIZE];
|
||||
std::string str{};
|
||||
|
||||
if(0 == uv_get_process_title(buf, size)) {
|
||||
str.assign(buf, size);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the current process title.
|
||||
* @param title The process title to be set.
|
||||
* @return True in case of success, false otherwise.
|
||||
*/
|
||||
static bool processTitle(std::string title) {
|
||||
return (0 == uv_set_process_title(title.c_str()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets memory information (in bytes).
|
||||
* @return Memory information.
|
||||
|
||||
@ -99,4 +99,7 @@ TEST(Util, Utilities) {
|
||||
ASSERT_FALSE(uvw::Utilities::exepath().empty());
|
||||
ASSERT_FALSE(uvw::Utilities::cwd().empty());
|
||||
ASSERT_TRUE(uvw::Utilities::chdir(uvw::Utilities::cwd()));
|
||||
|
||||
ASSERT_NE(uvw::Utilities::processTitle(), std::string{});
|
||||
ASSERT_TRUE(uvw::Utilities::processTitle(uvw::Utilities::processTitle()));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user