Esempio n. 1
0
stream_t* stream_open( const char* path, unsigned int mode )
{
	unsigned int protocol_end;

	//Check if protocol was given
	protocol_end = string_find_string( path, "://", 0 );
	if( protocol_end != STRING_NPOS )
	{
		//TODO: Proper pluggable protocol handling
#if FOUNDATION_PLATFORM_ANDROID
		if( ( protocol_end == 5 ) && string_equal_substr( path, "asset", 5 ) )
			return asset_stream_open( path, mode );
		else
#endif
		if( ( protocol_end == 4 ) && string_equal_substr( path, "file", 4 ) )
			return fs_open_file( path, mode );
		else if( ( protocol_end == 4 ) && string_equal_substr( path, "stdout", 4 ) )
			return stream_open_stdout();
		else if( ( protocol_end == 4 ) && string_equal_substr( path, "stderr", 4 ) )
			return stream_open_stderr();
		else if( ( protocol_end == 4 ) && string_equal_substr( path, "stdin", 4 ) )
			return stream_open_stdin();
		else if( ( protocol_end != 3 ) || !string_equal_substr( path, "vfs", protocol_end ) )
		{
			log_errorf( 0, ERROR_INVALID_VALUE, "Invalid protocol: %s", path );
			return 0;
		}
	}

	//No protocol, assume virtual file system path
	//TODO: Virtual file system

	return fs_open_file( path, mode );
}
Esempio n. 2
0
static stream_t*
_stream_open_stdout(const char* path, size_t length, unsigned int mode) {
	FOUNDATION_UNUSED(path);
	FOUNDATION_UNUSED(length);
	stream_t* stream = stream_open_stdout();
	stream->mode = (mode & STREAM_BINARY) | STREAM_OUT;
	return stream;
}