public function generate() {
        if (!$this->filePath) {
            throw new Exception('Trying to save file without path');
        }
        
        $tempDir = codemonkey_pathTempDir;
        
        $content = $this->generateCode();
        
        $this->checkIfTempFolderExists();
        $this->checkIfFoldersExist();
        
        try {
            $fp = fopen($tempDir.$this->filePath, 'w');
            fputs($fp, $content);
            fclose($fp);
            chmod($tempDir.$this->filePath, 0775);
        } catch (Exception $e) {
            echo "Could not generate file ".$this->filePath."<br />\n"
                    . $e->getMessage()."<br />\n";
        }
    }