Distribute generated files to their final destination

@param $tmpDir
@return array|bool
349014
protected function distribute($tmpDir)
    {
        // copy fonts
        foreach(glob($tmpDir . '/fonts/tao.*') as $font) {
            if(!copy($font, $this->taoDir . '/views/css/font/tao/' . basename($font))) {
                return array('error' => 'Failed to copy ' . $font);
            }
        };

        // copy icon scss
        foreach(glob($tmpDir . '/_tao-icon-*.scss') as $scss) {
            if(!copy($scss, $this->taoDir . '/views/scss/inc/fonts/' . basename($scss))) {
                return array('error' => 'Failed to copy ' . $scss);
            }
        };

        // copy ck editor styles
        if(!copy($tmpDir . '/_ck-icons.scss', $this->taoDir . '/views/js/lib/ckeditor/skins/tao/scss/inc/_ck-icons.scss')) {
            return array('error' => 'Failed to copy ' . $tmpDir . '/_ck-icons.scss');
        }

        // copy helper class
        if(!copy($tmpDir . '/class.Icon.php', $this->taoDir . '/helpers/class.Icon.php')) {
            return array('error' => 'Failed to copy ' . $tmpDir . '/class.Icon.php');
        }

        // copy selection to assets
        if(!copy($tmpDir . '/selection.json', $this->assetDir . '/selection.json')) {
            return array('error' => 'Failed to copy ' . $tmpDir . '/selection.json');
        }

        return true;
    }
942466
public static function detect_format($tempdir) {
        $filepath = make_backup_temp_directory($tempdir, false);
        if (!is_dir($filepath)) {
            throw new convert_helper_exception('tmp_backup_directory_not_found', $filepath);
        }
        $manifest = cc2moodle::get_manifest($filepath);
        if (!empty($manifest)) {
            // Looks promising, lets load some information.
            $handle = fopen($manifest, 'r');
            $xml_snippet = fread($handle, 1024);
            fclose($handle);

            // Check if it has the required strings.

            $xml_snippet = strtolower($xml_snippet);
            $xml_snippet = preg_replace('/\s*/m', '', $xml_snippet);
            $xml_snippet = str_replace("'", '', $xml_snippet);
            $xml_snippet = str_replace('"', '', $xml_snippet);

            $search_string = "xmlns=http://www.imsglobal.org/xsd/imscc/imscp_v1p1";
            if (strpos($xml_snippet, $search_string) !== false) {
                return backup::FORMAT_IMSCC1;
            }
        }

        return null;
    }
859947
public function restrictAsFiles(&$files, &$srcDir, &$destDir, &$mapper)
    {
        $res = $this->restrict($files, $srcDir, $destDir, $mapper);
        $result = [];
        for ($i = 0, $resultsCount = count($res); $i < $resultsCount; $i++) {
            $result[$i] = new PhingFile($srcDir, $res[$i]);
        }

        return $result;
    }
245479
def tmpdir(self):
        """"""
        if self._tmpdir is None:
            self._tmpdir = tempfile.mkdtemp(prefix="igraph.")
            atexit.register(cleanup_tmpdir, self._tmpdir)
        return self._tmpdir
843758
public function moveToDirectory($directory)
    {
        $targetPath = rtrim($directory, '/') . '/' . $this->getClientFilename();

        return $this->moveTo($targetPath);
    }
329894
def get_tmpdir():
    
    global __tmpdir
    if __tmpdir is not None:
        return __tmpdir

    __tmpdir = tempfile.mkdtemp(prefix='.tmp.glerbl.', dir=".")
    atexit.register(__clean_tmpdir)

    return __tmpdir
106221
private function _createTargetDir()
    {
        if (!$this->_targetDir) {
            return false;
        }
        $targetDir = rtrim($this->_targetDir, '/');
        if (!file_exists($targetDir)) {
            if (!@mkdir($targetDir, 0777, true)) {
                return false;
            }
        }
        return true;
    }
672340
private function getTmpPath(): string
    {
        $tmpDir = sys_get_temp_dir();
        if (!empty($this->prefix)) {
            $tmpDir .= '/' . $this->prefix;
        }
        $tmpDir .= '/' . $this->id;
        return $tmpDir;
    }
616977
public static function rmdir( $dir ) {
		$files = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS ),
			RecursiveIteratorIterator::CHILD_FIRST
		);

		foreach ( $files as $fileinfo ) {
			$todo = $fileinfo->isDir() ? 'rmdir' : 'unlink';
			$todo( $fileinfo->getRealPath() );
		}
		rmdir( $dir );
	}
720394
public function main($tempDir = null)
    {
        if (empty($tempDir)) {
            $tempDir = Configure::read('Attachments.tmpUploadsPath');
        }

        if (!Folder::isAbsolute($tempDir)) {
            $this->out('The path must be absolute, "' . $tempDir . '" given.');
            exit;
        }

        $Folder = new Folder();
        if ($Folder->cd($tempDir) === false) {
            $this->out('Path "' . $tempDir . '" doesn\'t seem to exist.');
            exit;
        }

        $dir = new Folder($tempDir);
        $folders = $dir->read();
        $files = $dir->findRecursive();
        $deletedFiles = 0;
        $deletedFolders = 0;

        $this->out('Found ' . count($folders[0]) . ' folders and ' . count($files) . ' files');

        foreach ($files as $filePath) {
            $file = new File($filePath);
            // only delete if last change is longer than 24 hours ago
            if ($file->lastChange() < (time() - 24 * 60 * 60) && $file->delete()) {
                $deletedFiles++;
            }
            $file->close();
        }

        foreach ($folders[0] as $folderName) {
            $folder = new Folder($dir->pwd() . DS . $folderName);
            // only delete if folder is empty
            if ($folder->dirsize() === 0 && $folder->delete()) {
                $deletedFolders++;
            }
        }


        $this->out('Deleted ' . $deletedFolders . ' folders and ' . $deletedFiles . ' files.');
    }
128520
private function get_path_publish_dir(){
		if( @!strlen( $this->px->conf()->path_publish_dir ) ){
			return false;
		}
		$tmp_path = $this->px->fs()->get_realpath( $this->px->conf()->path_publish_dir.'/' );
		if( !$this->px->fs()->is_dir( $tmp_path ) ){
			return false;
		}
		if( !$this->px->fs()->is_writable( $tmp_path ) ){
			return false;
		}
		return $tmp_path;
	}
644272
public function delDir($dir)
    {
        $dir = $this->checkpath($dir);
        if (@!ftp_rmdir($this->linkid, $dir)) {
            $this->close();
            return false;
        }
        $this->close();
        return true;
    }
329933
private function getFilePath()
    {

        $tmpDir = realpath($this->getContainer()->get('kernel')->getRootDir() . '/../var/tmp/');
        $fileName = '/' . str_replace(':', '--', $this->getName()) . '.sock';

        if (!file_exists($tmpDir)) {
            mkdir($tmpDir);
        }

        return $tmpDir . $fileName;
    }
825980
public static function destroyAllProgress()
    {
        // Get all filenames within the temporary folder
        $files = glob($tmpdir.'*');

        // Iterate through files
        $output = array();
        foreach ($files as $file) 
        {
            if (is_file($file)) 
            {
                // Return result to array
                $result = unlink($file);
                array_push($output, var_export($result, true));
            }
        }

        // If a file could not be deleted, return false
        if (array_search('false', $output)) 
        {
            return false;
        }

        return true;
    }
194474
public function makeDirectory($mode = FileSystemPermission::NORMAL)
    {
        $directoryId = $this->generateId();
        $path = sys_get_temp_dir() . '/' . $directoryId;
        $directory = new TemporaryDirectory($path, $mode);

        return $directory;
    }
384062
public function dirExists($dir)
    {
        return ($this->isConnected() === true) ? ftp_rmdir($this->connectionString.$dir) : false;
    }
1088356
protected function getTmpPath()
        {
            $tmpDir = sys_get_temp_dir();

            if (!empty($this->prefix)) {
                $tmpDir .= DIRECTORY_SEPARATOR . $this->prefix;
            }

            $tmpDir .= DIRECTORY_SEPARATOR . uniqid('run-', true);

            return $tmpDir;
        }