PEAR logo

PEAR_PackageFileManager : The Definitive Guide



Converting file line endings

Windows and Unix platform handle end-of-line in a specific way that you should take care if you don't want to have surprise at run-time.

Windows convert line endings to \r\n, while Unix convert line endings to \n. You may decides to prevent problem at package-time, as well as at install-time, and adding two basic tasks : <tasks:windowseol>, and <tasks:unixeol>.

[Note] Note
This feature is only available for package.xml, version 2.0

In this example we have two files pear-phpdoc and pear-phpdoc.bat that only one version should be installed at run-time. We will see later how to specify this condition.

  1. <?php
  2. require_once 'PEAR/PackageFileManager2.php';
  3.  
  4. PEAR::setErrorHandling(PEAR_ERROR_DIE);
  5.  
  6. $p2 = new PEAR_PackageFileManager2();
  7. //...
  8. $p2->addUnixEol('pear-phpdoc');
  9. $p2->addWindowsEol('pear-phpdoc.bat');
  10. ?>
PEAR_PackageFileManager : The Definitive Guide v 1.6.0 : November 17, 2006