Actually change the mode for the file.

@param  PhingFile $file
@param  int $mode
@throws BuildException
@throws Exception
496723
private function chmodFile(PhingFile $file, $mode)
    {
        if (!$file->exists()) {
            throw new BuildException("The file " . $file->__toString() . " does not exist");
        }

        try {
            $file->setMode($mode);
            if ($this->verbose) {
                $this->log("Changed file mode on '" . $file->__toString() . "' to " . vsprintf("%o", [$mode]));
            }
        } catch (Exception $e) {
            if ($this->failonerror) {
                throw $e;
            } else {
                $this->log($e->getMessage(), $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN);
            }
        }
    }
1089510
public static function setFile($file)
    {
        if (is_file($file)) {
            $options = Yaml::parse(file_get_contents($file));
            self::$instance = new self($options);
            self::$instance->validateOptions();
        } else {
            throw new Exception("Can't find config file at ".$file);
        }
    }
480464
public static function setDefaultMode(int $mode) : void
    {
        if (in_array($mode, [self::MODE_REGEX, self::MODE_STRING])) {
            self::$mode = $mode;
            return;
        }

        // Unknown mode
        throw new \UnexpectedValueException('Invalid route mode');
    }
877891
public function renameTo(PhingFile $destFile)
    {
        $fs = FileSystem::getFileSystem();
        if ($fs->checkAccess($this) !== true) {
            throw new IOException("No write access to " . $this->getPath());
        }

        $fs->rename($this, $destFile);
    }
1141342
public static function setNewSymbolicLinkMode(string $mode = '740'): void
    {
        static::init();
        static::$newSymlinkMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740;
    }
399106
protected function _open($mode)
    {
        $this->_fileHandler = @bzopen($this->_filePath, $mode);

        if (false === $this->_fileHandler) {
            throw new Mage_Exception('Failed to open file ' . $this->_filePath);
        }
    }
1310281
public static function setNewDirectoryMode(string $mode = '740'): void
    {
        static::init();
        static::$newDirectoryMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740;
    }
144099
public function setLoggingMode($mode, $filename = NULL) {
		$this->logging_mode = $mode;
		$this->log_filename = $filename;
	}
395643
public function setWriteMode($mode)
    {
        if (!in_array($mode, $this->validWriteModes, true)) {
            throw new InvalidArgumentException("Invalid write mode specified: $mode");
        }

        $this->config["writeMode"] = $mode;
        $this->createFileHandler();
    }
961665
public function setBuildFile($buildFile)
    {
        if (!file_exists($this->getDirectory() . $buildFile)) {
            throw new \Exception(Lang::get('build_file_missing'));
        }

        $this->buildFile = $buildFile;
    }
866109
protected function _open($mode)
    {
        $this->_fileHandler = @fopen($this->_filePath, $mode);

        if (false === $this->_fileHandler) {
            throw new Mage_Exception('Failed to open file ' . $this->_filePath);
        }
    }
1335681
public function open($filename, $mode = self::modeRead) {
    if (!in_array($mode, array(self::modeRead, self::modeWrite, self::modeReadWrite))) {
      throw new \Exception("Unkown file open mode");
    }

    $this->f = fopen($filename, $mode);

    return $this->f != false;
  }
507813
public function write($file, $content = "", $mode = "w+")
    {

        $stream = $this->getFileStream($file, $mode);

        //Write the contents
        fwrite($stream, $content);
        fclose($stream);

        return true;
    }
1177484
public static function createFile($file, $mode = 0775)
    {
        if (empty($file)) return false;
        if (is_file($file)) {
            return true;
        }
        $dir = dirname($file);
        self::createDir($dir);
        $fh = @fopen($file, 'a');
        if ($fh) {
            fclose($fh);
            return true;
        }
        return false;
    }
281845
public function setPaymentMode($mode)
    {

        try {
            if ($mode instanceof PagSeguroPaymentMode) {
                $this->paymentMode = $mode;
            } else {
                $this->paymentMode = new PagSeguroPaymentMode($mode);
            }
        } catch (Exception $e) {
            die($e->getMessage());
        }
    }
77467
protected function addModesFromFile($dir,$file)
    {
        $dir = $this->parseDir($dir);

        $jsContent = $file->getContents();
        preg_match_all('#defineMIME\(\s*(\'|")([^\'"]+)(\'|")#', $jsContent, $modes);
        if (count($modes[2])) {
            foreach ($modes[2] as $mode) {
                $this->addMode($mode, $dir."/".$file->getRelativePathname());
            }
        }
        $this->addMode($file->getRelativePath(), $dir."/".$file->getRelativePathname());

                #save to cache if env prod
        if ($this->env == 'prod') {
            $this->cacheDriver->save(static::CACHE_MODES_NAME, $this->getThemes());
        }
    }
893798
protected function set_mode(string $mode):void{
		$mode = strtolower($mode);

		if(!in_array($mode, ['totp', 'hotp'], true)){
			throw new AuthenticatorException('Invalid mode: '.$mode);
		}

		$this->mode = $mode;
	}