coc仓库--popen命令的封装

popen命令的封装

1.源码

int runShellNoReturn(const char *cmd, const char *mode)
{
    FILE *file = popen(cmd, mode);
    if (file == NULL)
    {
        return 1;
    }
    else
    {
        pclose(file);
        return 0;
    }
}

FILE *runShellAndReturn(const char *cmd, const char *mode)
{
    FILE *file = popen(cmd, mode);
    if (file == NULL)
    {
        return NULL;
    }
    else
    {
        return file;
    }
}

2.函数解析

函数很简单。无须多言。

posted @ 2023-07-18 22:37  (⊃・ᴥ・)つ  阅读(12)  评论(0编辑  收藏  举报