Esempio n. 1
0
File: file.c Progetto: gvx/deja
V load_file(V file_name, V global)
{
	if (file_name == NULL || getType(file_name) != T_STR)
	{
		clear_ref(file_name);
		return NULL;
	}
	FILE* f = fopen(toNewString(file_name)->text, "rb");
	if (f == NULL)
	{
		clear_ref(file_name);
		return NULL;
	}
	fseek(f, 0, SEEK_END);
	size_t length = ftell(f);
	rewind(f);
	char *data = malloc(length * sizeof(char));
	size_t read = fread(data, sizeof(char), length, f);
	assert (read == length);
	V new_file = load_memfile(data, length, file_name, global);
	free(data);
	fclose(f);
	clear_ref(file_name);
	return new_file;
}
Esempio n. 2
0
File: io.c Progetto: jpcoles/cello
int load_timestep()
{
    switch (env.cfg.input_filetype)
    {
        case TIPSY_STANDARD:
            load_standard_tipsy(env.cfg.base_input_filename);
            break;
        case TIPSY_NATIVE:
            load_native_tipsy(env.cfg.base_input_filename);
            break;
        case ASCII:
            load_ascii(env.cfg.base_input_filename);
            break;
        case MEM_FILE:
            load_memfile(env.cfg.base_input_filename);
            break;
        default:
            myassert(0, "Tried to load file, but the filetype is wrong.");
            break;
    }

    return 0;
}