question - php_stream_cast(...) and PHP_STREAM_AS_FD

From: Date: Mon, 09 Feb 2004 15:25:01 +0000
Subject: question - php_stream_cast(...) and PHP_STREAM_AS_FD
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-409@lists.php.net to get a copy of this message
I'm trying to open a php stream and cast it as an fd so I can use it with a third party library that expects an fd to read from sound files. This is all fine and well for read mode but when I try to open the file in write mode, it opens it in read instead. I'm fully aware that the stream must be opened in the same mode as I'm opening the file with (the fd) but I'm not sure if I have the cast correct. Heres a snippet: // ... from php_stream * php_stream_sf_open(... // ... self = (struct php_sf_stream_data_t *) emalloc(sizeof(*self)); innerstream = php_stream_open_wrapper(path, mode, STREAM_MUST_SEEK | options | STREAM_WILL_CAST, opened_path); if (innerstream) { self->mode = strchr(mode, 'r') ? SFM_READ : SFM_WRITE; if (php_stream_cast(innerstream, PHP_STREAM_AS_FD | PHP_STREAM_CAST_RELEASE, (void **) &self->fd, REPORT_ERRORS) == SUCCESS) { self->sf = sf_open_fd(self->fd, self->mode, &self->sfinfo, SF_TRUE); // ... more stuff Works fine for me when opened in read mode but also opens in read when I specify write. Do I have the cast written correctly? -- Justin Hannus Lead Programmer/Web Development jhannus@visualconceptsinc.com www.visualconceptsinc.com [860] 242.1150 ext.125 [860] 242.1446 fax

« previous php.pecl.dev (#409) next »