Example #1
0
/* {{{ inifile_alloc */
inifile * inifile_alloc(php_stream *fp, int readonly, int persistent TSRMLS_DC)
{
	inifile *dba;

	if (!readonly) {
		if (!php_stream_truncate_supported(fp)) {
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't truncate this stream");
			return NULL;
		}
	}
 
	dba = pemalloc(sizeof(inifile), persistent);
	memset(dba, 0, sizeof(inifile));
	dba->fp = fp;
	dba->readonly = readonly;
	return dba;
}
Example #2
0
static HRESULT STDMETHODCALLTYPE stm_set_size(IStream *This, ULARGE_INTEGER libNewSize)
{
	FETCH_STM();

	if (libNewSize.HighPart) {
		return STG_E_INVALIDFUNCTION;
	}

	if (php_stream_truncate_supported(stm->stream)) {
		int ret = php_stream_truncate_set_size(stm->stream, (size_t)libNewSize.QuadPart);

		if (ret == 0) {
			return S_OK;
		}
	}

	return STG_E_INVALIDFUNCTION;
}