修复部分BUG
This commit is contained in:
@@ -17,7 +17,7 @@ namespace ylib
|
||||
std::string path()
|
||||
{
|
||||
if (__filepath.empty())
|
||||
return ylib::process::getpath(pid);
|
||||
__filepath = ylib::process::getpath(pid);
|
||||
return __filepath;
|
||||
}
|
||||
std::string __filepath;
|
||||
@@ -32,7 +32,7 @@ namespace ylib
|
||||
// 系统进程列表
|
||||
std::list<ylib::process::proc_info> list();
|
||||
// 是否存在
|
||||
bool exist(const std::string& filepath);
|
||||
size_t exist(const std::string& filepath);
|
||||
// 检测多开
|
||||
bool already_running(const std::string& name);
|
||||
// 设置为启动
|
||||
|
||||
@@ -27,9 +27,9 @@ bool ylib::process::create(const std::string& filepath, const std::string& worki
|
||||
|
||||
// 构建命令行字符串
|
||||
std::stringstream ss;
|
||||
ss << "\"" << filepath << "\"";
|
||||
ss << filepath<<" ";
|
||||
for (const auto& arg : args) {
|
||||
ss << " \"" << arg << "\"";
|
||||
ss << " "<<arg<<" ";
|
||||
}
|
||||
std::string cmd = ss.str();
|
||||
std::vector<char> cmdCStr(cmd.begin(), cmd.end());
|
||||
@@ -129,15 +129,17 @@ std::string ylib::process::getpath(uint32 process_id)
|
||||
return path;
|
||||
#endif
|
||||
}
|
||||
bool ylib::process::exist(const std::string& filepath)
|
||||
size_t ylib::process::exist(const std::string& filepath)
|
||||
{
|
||||
auto list = process::list();
|
||||
for_iter(iter, list)
|
||||
{
|
||||
if (strutils::change_case(iter->path(), false) == strutils::change_case(filepath, false))
|
||||
return true;
|
||||
{
|
||||
return iter->pid;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
// 检测多开
|
||||
bool ylib::process::already_running(const std::string& name)
|
||||
|
||||
Reference in New Issue
Block a user