AppserverIo\Appserver\Meta\Composer\Script\Setup::copyOsSpecificResource PHP Method

copyOsSpecificResource() public static method

Copies the passed OS specific resource file to the target directory.
public static copyOsSpecificResource ( string $os, string $resource, boolean $override = false, integer $mode = 420 ) : void
$os string The OS we want to copy the files for
$resource string The resource file we want to copy
$override boolean TRUE if the file should be overwritten if exists, else FALSE
$mode integer The mode of the target file
return void
    public static function copyOsSpecificResource($os, $resource, $override = false, $mode = 0644)
    {
        // we need the installation directory
        $installDir = Setup::getValue(SetupKeys::INSTALL_DIR);
        // prepare source and target directory
        $source = Setup::prepareOsSpecificPath(sprintf('%s/resources/os-specific/%s/%s', $installDir, $os, $resource));
        $target = Setup::prepareOsSpecificPath(sprintf('%s/%s', $installDir, $resource));
        // query whether we've to override the file
        if ($override === false && is_file($target) === true) {
            return;
        }
        // prepare the target directory
        Setup::prepareDirectory($target);
        // copy the file to the target directory
        copy($source, $target);
        // set the correct mode for the file
        Setup::changeFilePermissions($target, $mode);
    }