Exemplo n.º 1
0
static char* rio_write_path(void)
{
    const char* writepath = arg_value("-writepath", NULL);
    const char* writename = arg_value("-writename", NULL);
    char* awdir = writepath ? strdup(writepath) : rio_system_write_path();
    char* fdir;
    char* dir;
    size_t i;

    if (writepath) {
        fdir = unipath(writepath);
        free(awdir);
        return fdir;
    }

    if (writename) {
        fdir = strdup(writename);
    } else {
        if (arg_value("-game", NULL)) {
            fdir = strdup(dirs->first->ptr);
        } else {
            fdir = strdup("");
        }
    }

    dir = malloc(strlen(awdir) + strlen(fdir) + 256);
    sprintf(dir, "%s%s", awdir, fdir);

    free(fdir);
    free(awdir);
    fdir = unipath(dir);
    free(dir);
    return fdir;
}
Exemplo n.º 2
0
    virtual const char* what() const throw()
    {
        if ( message_.empty() )
        {
            std::ostringstream ss;
            ss << test_->name() << " [" << test_->file() << ": " << line_ << "]\n";

            switch ( type_ )
            {

            case UNKNOWN:
                ss << "\t" << what_;
                break;

            case UNARY_CHECK:
                ss << "\t" << check_ << "( " << arg( 0 ) << " ) failed\n\twith ";
                ss << arg( 0 ) << " = " << arg_value( 0 );
                ss << " < " << arg_type( 0 ) << " >\n";
                break;

            case BINARY_CHECK:
                ss << "\t" << check_ << "( " << arg( 0 ) << ", " << arg( 1 )
                   << " ) failed\n\twith:\n\t\t";

                ss << arg( 0 ) << " = " << arg_value( 0 )
                   << " < " << arg_type( 0 ) << " >\n\t\t";

                ss << arg( 1 ) << " = " << arg_value( 1 )
                   << " < " << arg_type( 1 ) << " >\n\t\t";

                break;

            case THROW_CHECK:
                ss << "\t" << check_ << "( " << arg( 0 );
                if ( arg( 1 ) ) {
                    ss << ", " << arg( 1 );
                }
                ss << " ) failed\n\t";
                if ( what_.empty() ) {
                    ss << "No exception was thrown\n";
                } else {
                    ss << "Wrong exception was thrown\n\twhat():  " << what_;
                }

            default:
                break;

            }

            std::string &msg_ = const_cast< std::string& >( message_ );
            msg_ = ss.str();

        }
        return message_.c_str();
    }
Exemplo n.º 3
0
// Parse the arguments of the program.
// Accept arguments of form : -variable=value
// Arguments like -flag are considered as -flag=true
std::vector<argument> parse_args(int argc, char* argv[])
{
	std::vector<argument> arguments;

	for(int i(0) ; i < argc ; ++i)
	{
		char* arg = argv[i];
		std::stringstream ss(arg);

        std::string arg_var("");
        std::string arg_value("");

        std::getline(ss, arg_var, '=');
        std::getline(ss, arg_value, '\n');

        argument current_arg;

		if(arg_value == "")
		{
			current_arg.name = arg_var;
			current_arg.value = "true";
		}
		else
		{
			current_arg.name = arg_var;
			current_arg.value = arg_value;
		}

		arguments.push_back(current_arg);
	}

	return arguments;
}
Exemplo n.º 4
0
int rio_init(void)
{
    char* datapath = rio_system_datapath();
    const char* gamepath = arg_value("-game", datapath);
    char* tmp = malloc(strlen(gamepath) + 256);
    size_t i;
    dirs = list_new();
    dirs->item_free = free;

    rio_mountdir(gamepath);
    for (i=0; i<10; i++) {
        sprintf(tmp, "%s/alp%i.alp", gamepath, i);
        rio_mountalp(tmp);
    }

    free(tmp);
    free(datapath);
    return 0;
}
Exemplo n.º 5
0
static char* rio_system_write_path(void)
{
    return unipath(getApplicationWriteDirectory(arg_value("-appname", GAME_TITLE)));
}