Craft\AmForms_ExportsService::getTempExportFiles PHP Method

getTempExportFiles() public method

Note: these files were created by single submission export.
public getTempExportFiles ( array $exports = [] ) : boolean | array
$exports array Array with AmForms_ExportModel to be able to skip files.
return boolean | array
    public function getTempExportFiles($exports = array())
    {
        // Get exports folder path
        $folder = $this->_getExportPath();
        if (!is_dir($folder)) {
            return false;
        }
        // Gather files
        $tempFiles = array();
        $skipFiles = array();
        // Do we have any exports available?
        if (is_array($exports) && count($exports)) {
            foreach ($exports as $export) {
                $skipFiles[] = $export->file;
            }
        }
        // Find temp files
        $handle = opendir($folder);
        while (($file = readdir($handle)) !== false) {
            if ($file === '.' || $file === '..' || substr($file, 0, 1) == '.') {
                continue;
            }
            if (!in_array($folder . $file, $skipFiles)) {
                $tempFiles[] = $folder . $file;
            }
        }
        closedir($handle);
        // Return files if found any!
        return count($tempFiles) ? $tempFiles : false;
    }