public static function addRequiredResources($sourceDirectory, $relativeSourceFiles, $prefix, core_kernel_classes_Resource $item, $lang)
    {

        $returnValue = array();

        $directory = taoItems_models_classes_ItemsService::singleton()->getItemDirectory($item, $lang);
        
        foreach ($relativeSourceFiles as $relPath) {

            if(! tao_helpers_File::securityCheck($relPath, true)) {
                throw new common_exception_Error('Invalid resource file path');
            }
                
            $relPath = preg_replace('/^\.\//', '', $relPath);
            $source = $sourceDirectory . $relPath;

            $fh = fopen($source, 'r');
            if (! is_resource($fh)) {
                throw new common_exception_Error('The resource "' . $source . '" cannot be copied.');
            }

            $path = tao_helpers_File::concat(array(
                $prefix ? $prefix : '',
                $relPath
            ));

            // cannot write as PCI do not get cleaned up
            if ($directory->getFile($path)->put($fh)) {
                $returnValue[] = $relPath;
            }
            fclose($fh);
        }

        return $returnValue;
    }