Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:1260 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97497 invoked by uid 1007); 5 May 2003 11:26:38 -0000 Message-ID: <20030505112638.97495.qmail@pb1.pair.com> To: internals@lists.php.net Date: Mon, 05 May 2003 21:27:12 +1000 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 References: <1051831866.2944.10.camel@hemna.uh.nu> <20030505110212.72298.qmail@pb1.pair.com> <20030505111940.92012.qmail@pb1.pair.com> In-Reply-To: <20030505111940.92012.qmail@pb1.pair.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 203.37.117.98 Subject: Re: domDoc class uses flock() From: tk.lists@fastmail.fm (Terence) There are two other methods I should have included (which explains why I haven't closed the resource in DOMDOC_AS_WRITEFILE mode. I realise this question is borderline internals/general but no one in the user community seems to be equipped to answer it for me. I appologies if I have made an error in this judgement. /** * mass storage serialisation * * This function will dump the textual contents of the DOM document (in it's * current state to) file. * * @param uri path to destination file * @return bool success or failure */ function Commit() { if($this->mode == DOMDOC_AS_WRITEFILE) { fwrite($this->fp,$this->xmlGetDoc()); flock($this->fp,LOCK_UN); fclose($this->fp); } else { return $this->objErr->throw( "Commit() can only be used when domDoc is invoked in " ."DOMDOC_AS_WRITEFILE mode" ); } return true; } /** * mass storage serialisation * * This function will dump the textual contents of the DOM document (in it's * current state to) a specified file. * * @param uri path to destination file * @return bool success or failure */ function CommitToFile($uriDestination) { $fp = fopen($uriDestination,"w+") or $this->objErr->throw("CommitToFile: could not open ".$uriDestination." for writing"); flock($fp,LOCK_EX); fwrite($fp,$this->xmlGetDoc()) or $this->objErr->throw("CommitToFile: could write to ".$uriDestination); flock($fp,LOCK_UN); fclose($fp); return true; }