Example #1
0
bool CGrayInstall::OpenFile( CGFile & file, LPCTSTR pszName, WORD wFlags )
{
	ASSERT(pszName);
	if ( !m_sPreferPath.IsEmpty() )
	{
		if ( file.Open(GetPreferPath(pszName), wFlags) )
			return true;
	}
	else
	{
		if ( file.Open(GetFullExePath(pszName), wFlags) )
			return true;
		if ( file.Open(GetFullCDPath(pszName), wFlags) )
			return true;
	}
	return false;
}
Example #2
0
static int ExecuteCommand(const char *program, const char *arg)
{
    pid_t childpid;
    int result;
    const char *argv[3];

    childpid = fork();

    if (childpid == 0) 
    {
        // This is the child.  Execute the command.

        argv[0] = GetFullExePath(program);
        argv[1] = arg;
        argv[2] = NULL;

        execvp(argv[0], (char **) argv);

        exit(0x80);
    }
    else
    {
        // This is the parent.  Wait for the child to finish, and return
        // the status code.

        waitpid(childpid, &result, 0);

        if (WIFEXITED(result) && WEXITSTATUS(result) != 0x80) 
        {
            return WEXITSTATUS(result);
        }
        else
        {
            return -1;
        }
    }
}