Flags the archive in specific states of extraction

@param \SplFileInfo $archive The archive to flag
@param string       $flag    The flag to set

@return void
422081
public function flagArchive(\SplFileInfo $archive, $flag)
    {
        // delete all old flags
        $this->unflagArchive($archive);
        // flag the passed archive
        file_put_contents($archive->getPathname() . $flag, $archive->getPathname());
        // set correct user/group for the flag file
        $this->setUserRight(new \SplFileInfo($archive->getPathname() . $flag));
    }
1049807
private function unsubscribeStreamEvent($stream, $flag)
    {
        $key = (int) $stream;

        $flags = $this->streamFlags[$key] &= ~$flag;

        if (0 === $flags) {
            $this->removeStream($stream);

            return;
        }

        $event = $this->streamEvents[$key];

        event_del($event);
        event_set($event, $stream, EV_PERSIST | $flags, $this->streamCallback);
        event_add($event);
    }
676408
public function withFlag(FlagInterface $flag): self
    {
        $clone = clone ($this);
        $clone->flags[$flag->__toString()] = deep_clone($flag);

        return $clone;
    }
93076
def remove_flag(self, flag):
        
        if self.has_flag(flag):
            del self._flags[flag.lower()]
721011
def _set_flag(self, flag):
        """"""
        self.folder._invalidate_cache()
        # TODO::: turn the flag off when it's already on
        def replacer(m):
            return "%s/%s.%s%s" % (
                joinpath(self.folder.base, self.folder.folder, "cur"),
                m.group("key"),
                m.group("hostname"),
                ":2,%s" % (
                    "%s%s" % (m.group("flags"), flag) if m.group("flags") \
                        else flag
                    )
                )
        newfilename = self.msgpathre.sub(replacer, self.filename)
        self.filesystem.rename(self.filename, newfilename)
        self.filename = newfilename
1349517
protected function setFlag($flag, $enable = true)
    {
        if ($enable) {
            $this->flags[$flag] = true;
        } else {
            unset($this->flags[$flag]);
        }
    }
89409
public function updateStatusFlags(&$flags)
    {
        // If there is no current FluentState, then we shouldn't update.
        if (!FluentState::singleton()->getLocale()) {
            return;
        }

        // If this page does not exist it should be "invisible"
        if (!$this->isDraftedInLocale() && !$this->isPublishedInLocale()) {
            $flags['fluentinvisible'] = [
                'text' => '',
                'title' => '',
            ];
        }
    }
799932
private function unsubscribeStreamEvent($stream, $flag)
    {
        $key = (int) $stream;

        $flags = $this->streamFlags[$key] &= ~$flag;

        if (0 === $flags) {
            $this->removeStream($stream);

            return;
        }

        $event = $this->streamEvents[$key];

        $event->del();
        $event->set($this->eventBase, $stream, Event::PERSIST | $flags, $this->streamCallback);
        $event->add();
    }
830341
private function validatePluginZip(string $prefix, \ZipArchive $archive): void
    {
        for ($i = 2; $i < $archive->numFiles; ++$i) {
            $stat = $archive->statIndex($i);

            $this->assertNoDirectoryTraversal($stat['name']);
            $this->assertPrefix($stat['name'], $prefix);
        }
    }
260738
public function isDeployable(\SplFileInfo $archive)
    {

        // check if the .dodeploy flag file exists
        if (file_exists($archive->getPathname() . ExtractorInterface::FLAG_DODEPLOY)) {
            return true;
        }

        // by default it's NOT deployable
        return false;
    }
448939
public function open($filename, $flags = null) {
        $result = parent::open($filename, $flags);

        if ($result === true)
            return parent::ER_OK;

        if (!is_int($result)) {
            Logger::log('ZipArchive::open() returned an invalid result: '.$result.' ('.gettype($result).')', L_ERROR);
            return parent::ER_INTERNAL;
        }
        if (!isset(static::$errors[$result]))
            Logger::log('ZipArchive::open() returned an unknown error: '.$result, L_WARN);

        return $result;
    }
967385
protected function extent($width, $height, $flag = '')
    {
        $this->commands['-extent %sx%s%s'] = [(string)$width, (string)$height, $flag];

        return $this;
    }
990505
protected function evalFlagSorting($config, $flag)
    {
        if (($flag < 0) || ($flag > 12)) {
            return;
        }

        if (1 === ($flag % 2)) {
            $config->setSortingMode(GroupAndSortingInformationInterface::SORT_ASC);
        } else {
            $config->setSortingMode(GroupAndSortingInformationInterface::SORT_DESC);
        }
    }
282855
public function flag() {
        global $DB;

        $this->ensure_fields_exist(array('name', 'userid', 'rawname', 'flag'), 'flag');

        // Update all the tags to flagged.
        $this->timemodified = time();
        $this->flag++;
        $DB->update_record('tag', array('timemodified' => $this->timemodified,
            'flag' => $this->flag, 'id' => $this->id));

        $event = \core\event\tag_flagged::create(array(
            'objectid' => $this->id,
            'relateduserid' => $this->userid,
            'context' => context_system::instance(),
            'other' => array(
                'name' => $this->name,
                'rawname' => $this->rawname
            )

        ));
        $event->trigger();
    }
1044366
public function delete($archive = true) {
        global $DB;

        if ($archive) {
            $this->status = BADGE_STATUS_ARCHIVED;
            $this->save();

            // Trigger event, badge archived.
            $eventparams = array('objectid' => $this->id, 'context' => $this->get_context());
            $event = \core\event\badge_archived::create($eventparams);
            $event->trigger();
            return;
        }

        $fs = get_file_storage();

        // Remove all issued badge image files and badge awards.
        // Cannot bulk remove area files here because they are issued in user context.
        $awards = $this->get_awards();
        foreach ($awards as $award) {
            $usercontext = context_user::instance($award->userid);
            $fs->delete_area_files($usercontext->id, 'badges', 'userbadge', $this->id);
        }
        $DB->delete_records('badge_issued', array('badgeid' => $this->id));

        // Remove all badge criteria.
        $criteria = $this->get_criteria();
        foreach ($criteria as $criterion) {
            $criterion->delete();
        }

        // Delete badge images.
        $badgecontext = $this->get_context();
        $fs->delete_area_files($badgecontext->id, 'badges', 'badgeimage', $this->id);

        // Delete endorsements, alignments and related badges.
        $DB->delete_records('badge_endorsement', array('badgeid' => $this->id));
        $relatedsql = 'badgeid = :badgeid OR relatedbadgeid = :relatedbadgeid';
        $relatedparams = array(
            'badgeid' => $this->id,
            'relatedbadgeid' => $this->id
        );
        $DB->delete_records_select('badge_related', $relatedsql, $relatedparams);
        $DB->delete_records('badge_alignment', array('badgeid' => $this->id));

        // Finally, remove badge itself.
        $DB->delete_records('badge', array('id' => $this->id));

        // Trigger event, badge deleted.
        $eventparams = array('objectid' => $this->id,
            'context' => $this->get_context(),
            'other' => array('badgetype' => $this->type, 'courseid' => $this->courseid)
            );
        $event = \core\event\badge_deleted::create($eventparams);
        $event->trigger();
    }
1145266
public function setStale($flag)
    {
        if (!is_bool($flag)) {
            $this->params['stale'] = $flag;
        } elseif ($flag === true) {
            $this->params['stale'] = 'ok';
        } else {
            unset($this->params['stale']);
        }

        return $this;
    }
63685
public function output($flags = 0x00003) {
    if (($flags & self::OUTPUT_HEADER) == self::OUTPUT_HEADER) {
      $this->sendHeaders();
    }
    
    if ($this->outputClosure instanceof \Closure) {
      $c = $this->outputClosure;
      $c();
      return;
    }
    
    if (($flags & self::OUTPUT_BODY) == self::OUTPUT_BODY) {
      print $this->body;
    }
  }