118d117
<       require_once './'. drupal_get_path('module', 'backup_migrate_files') .'/includes/Tar.php';
161,163c160,164
<     // Switch to the includes directory so that include will find local copies of PEAR.php and Tar.php
<     $dir = getcwd();
<     chdir('./' . drupal_get_path('module', 'backup_migrate_files') .'/includes');
---
>   	 $result = true;
> 
>   	 // extend inlcude path with path to this module's includes directory
>   	 $includesDirectory = './' . drupal_get_path('module', 'backup_migrate_files') . '/includes';
>     $includePathOld = set_include_path($includesDirectory . ';' . get_include_path());
166c167
<     include 'PEAR.php';
---
>     include_once 'PEAR.php';
169,170c170
<       chdir($dir);
<       return FALSE;
---
>       $result = false;
174,178c174,186
<     include 'Tar.php';
<     if (!class_exists('Archive_Tar')) {
<       _backup_migrate_message('Archive_Tar is not installed correctly. See the README.txt file in the backup_migrate_files module directory for help.', array(), 'error');
<       chdir($dir);
<       return FALSE;
---
>     if ($result) {
>       // try to get version in this module's includes directory first, but prevent warning texts being output
>       if (file_exists($includesDirectory . '/Tar.php')) {
>         include_once $includesDirectory . '/Tar.php';
>       }
>       if (!class_exists('Archive_Tar')) {
>         // try to get via PEAR directory structure
>         include_once 'Archive/Tar.php';
>         if (!class_exists('Archive_Tar')) {
>           _backup_migrate_message('Archive_Tar is not installed correctly. See the README.txt file in the backup_migrate_files module directory for help.', array(), 'error');
>           $result = false;
>         }
>       }
181,183c189,191
<     // If we got here then the files were included just fine.
<     chdir($dir);
<     return TRUE;
---
>     // clean up: restore include path
>     set_include_path($includePathOld);
>     return $result;
186d193
< 
