function mock_fsmerge( & $fs, & $comp) {
		if (isset($comp['%type']) && $comp['%type'] == 'file') {
			throw new \Exception('[Mock] Tried to copy file as directory.');
		}

		// map existing files
		$existing_files = [];
		foreach ($fs as $node => $file) {
			if (is_integer($node)) {
				$existing_files[] = $file['filename'];
			}
		}

		// merge
		foreach ($comp as $node => $file) {
			if (is_integer($node)) {
				if (in_array($file['filename'], $existing_files)) {
					throw new \Exception("[Mock] Tried to overwrite file: {$file['filename']}");
				}
				$fs[] = $file;
			}
			else if ($node[0] == '%') { // attribute
				$fs[$node] = $file;
			}
			else { // dir
				isset($fs[$node]) or $fs[$node] = [];
				$this->mock_fsmerge($fs[$node], $file);
			}
		}
	}
function mock_fsmerge( & $fs, & $comp) {
		if (isset($comp['%type']) && $comp['%type'] == 'file') {
			throw new \Exception('[Mock] Tried to copy file as directory.');
		}

		// map existing files
		$existing_files = [];
		foreach ($fs as $node => $file) {
			if (is_integer($node)) {
				$existing_files[] = $file['filename'];
			}
		}

		// merge
		foreach ($comp as $node => $file) {
			if (is_integer($node)) {
				if (in_array($file['filename'], $existing_files)) {
					throw new \Exception("[Mock] Tried to overwrite file: {$file['filename']}");
				}
				$fs[] = $file;
			}
			else if ($node[0] == '%') { // attribute
				$fs[$node] = $file;
			}
			else { // dir
				isset($fs[$node]) or $fs[$node] = [];
				$this->mock_fsmerge($fs[$node], $file);
			}
		}
	}
function mock_fsmerge ( & $ fs , & $ comp ) { if ( isset ( $ comp [ '%type' ] ) && $ comp [ '%type' ] == 'file' ) { throw new \ Exception ( '[Mock] Tried to copy file as directory.' ) ; } // map existing files $ existing_files = [ ] ; foreach ( $ fs as $ node => $ file ) { if ( is_integer ( $ node ) ) { $ existing_files [ ] = $ file [ 'filename' ] ; } } // merge foreach ( $ comp as $ node => $ file ) { if ( is_integer ( $ node ) ) { if ( in_array ( $ file [ 'filename' ] , $ existing_files ) ) { throw new \ Exception ( "[Mock] Tried to overwrite file: {$file['filename']}" ) ; } $ fs [ ] = $ file ; } else if ( $ node [ 0 ] == '%' ) { // attribute $ fs [ $ node ] = $ file ; } else { // dir isset ( $ fs [ $ node ] ) or $ fs [ $ node ] = [ ] ; $ this -> mock_fsmerge ( $ fs [ $ node ] , $ file ) ; } } }
Merges two file system definitions togheter.
Merges two file system definitions togheter .