Project

General

Profile

« Previous | Next » 

Revision 406ced77

Added by Renato Botelho over 8 years ago

Change safe_write_file $content parameter to accept an array

View differences:

src/etc/inc/config.lib.inc
384 384
 *   process, them renaming the temporary file over the original.
385 385
 * INPUTS
386 386
 *   $filename  - string containing the filename of the file to write
387
 *   $content   - string containing the file content to write to file
387
 *   $content   - string or array containing the file content to write to file
388 388
 *   $force_binary      - boolean denoting whether we should force binary
389 389
 *   mode writing.
390 390
 * RESULT
......
399 399
		// Unable to open temporary file for writing
400 400
		return false;
401 401
	}
402
	if (!fwrite($fd, $content)) {
402
	if (is_array($content)) {
403
		foreach ($content as $line) {
404
			if (!fwrite($fd, $line . "\n")) {
405
				// Unable to write to temporary file
406
				fclose($fd);
407
				return false;
408
			}
409
		}
410
	} elseif (!fwrite($fd, $content)) {
403 411
		// Unable to write to temporary file
404 412
		fclose($fd);
405 413
		return false;

Also available in: Unified diff