Open a zip file.

@param $location

@throws \LogicException if it cannot open the archive
8338
public function openArchive($location)
    {
        $location = str_replace('/', DIRECTORY_SEPARATOR, $location);
        if (($response = $this->archive->open($location, ZipArchive::CREATE)) !== true) {
            throw new \LogicException('Could not open zip archive at:'.$location.', error: '.$response);
        }
    }
105766
public function setStorageLocation(\Concrete\Core\Entity\File\StorageLocation\StorageLocation $location)
    {
        $this->storageLocation = $location;
    }
1272388
public function loadExternalClass($className, $location)
    {
        $filePath = $location.\DIRECTORY_SEPARATOR.
                    strtolower(str_replace('\\', \DIRECTORY_SEPARATOR, $className)).'.zep';

        /**
         * Fix the class name.
         */
        $className = implode('\\', array_map('ucfirst', explode('\\', $className)));

        if (isset($this->files[$className])) {
            return true;
        }

        if (!file_exists($filePath)) {
            return false;
        }

        /** @var CompilerFile|CompilerFileAnonymous $compilerFile */
        $compilerFile = $this->compilerFileFactory->create($className, $filePath);
        $compilerFile->setIsExternal(true);
        $compilerFile->preCompile($this);

        $this->files[$className] = $compilerFile;
        $this->definitions[$className] = $compilerFile->getClassDefinition();

        return true;
    }
1136331
public function indexLocation(Location $location)
    {
        $document = $this->mapper->mapLocation($location);

        $this->gateway->index($document);
    }
570935
private function loadLocation($locationId): Location
    {
        $location = $this->repository->sudo(
            function (Repository $repository) use ($locationId) {
                return $repository->getLocationService()->loadLocation($locationId);
            }
        );

        return $location;
    }
2992
def read(self, location):
        
        location = os.path.expanduser(location)

        # Try to open this file, using different encodings.
        for e in ENCODINGS:
            try:
                with codecs.open(location, 'r', e) as f:
                    return f.read(), e
            except UnicodeDecodeError:
                pass  # Try next codec.

        # Unable to open.
        raise Exception('Unable to open file: %r' % location)
1176531
public function insertVolume($entry, $location = null)
    {
        if ($location == null) {
            $uri = self::MY_LIBRARY_FEED_URI;
        } else {
            $uri = $location;
        }
        return parent::insertEntry(
            $entry, $uri, 'Zend_Gdata_Books_VolumeEntry');
    }
531021
public function matchLocation(Location $location)
    {
        $contentType = $this->repository
            ->getContentTypeService()
            ->loadContentType($location->getContentInfo()->contentTypeId);

        return isset($this->values[$contentType->identifier]);
    }
1207834
public function addSearchLocation($location)
    {
        if (!file_exists($location)) {
            throw new \InvalidArgumentException(
                sprintf("The location path %s is not valid.", $location)
            );
        }

        $this->searchLocations[] = $location;

        return $this;
    }
936489
private function open() {
        if (file_exists($this->target) && !unlink($this->target))
            throw new ZipExporterException("could not remove existing zip archive at \"$this->target\"");
        
        $zip = new \ZipArchive();
        if (!$zip->open($this->target, \ZipArchive::CREATE))
            throw new ZipExporterException("could not create zip archive at \"$this->target\"");
        return $zip;
    }
255969
private function open()
    {
        $this->fileHandle = fopen($this->path, "c+");
        if (!is_resource($this->fileHandle)) {
            throw new StorageException("Could not open '$this->path'.");
        }
        $this->mutex = new FlockMutex($this->fileHandle);
    }
963961
public function load(Location $location): self
    {
        $customUrlAliases = $this->urlAliasService->listLocationAliases($location, true, null, true);
        $this->data = array_map(
            function (URLAlias $urlAlias) {
                return $this->valueFactory->createUrlAlias($urlAlias);
            },
            $customUrlAliases
        );

        return $this;
    }
30705
protected function doesDirectoryExist($location)
    {
        // Maybe this isn't an actual key, but a prefix.
        // Do a prefix listing of objects to determine.
        $command = $this->s3Client->getCommand(
            'listObjects',
            [
                'Bucket'  => $this->bucket,
                'Prefix'  => rtrim($location, '/') . '/',
                'MaxKeys' => 1,
            ]
        );

        try {
            $result = $this->s3Client->execute($command);

            return $result['Contents'] || $result['CommonPrefixes'];
        } catch (S3Exception $e) {
            if ($e->getStatusCode() === 403) {
                return false;
            }

            throw $e;
        }
    }
1138548
public function setDirectory ($directory) {
        if (strpos($directory, '/') !== 0) {
            throw new Exception\InvalidArgumentException('Directory name must be an absolute path.');
        }

        if (!is_dir($directory)) {
            throw new Exception\LogicException('Template directory does not exist.');
        }

        $this->directory = realpath($directory);
    }
755669
public function save(string $location = null): FedoraResource {
        if ($this->uri != '') {
            $meta = $this->getMetadata();
            $meta->merge($this->getAclMetadata(), [RC::idProp()]);
            $this->setMetadata($meta);
            $this->updateMetadata();
        } else {
            if ($location === null) {
                throw new InvalidArgumentException('location parameter missing');
            }

            $meta      = $this->getAclMetadata();
            $meta->addResource(RC::idProp(), 'https://id.acdh.oeaw.ac.at/acl/' . microtime(true) . rand(0, 1000));
            $res       = $this->fedora->createResource($meta, '', $location, 'POST');
            $this->uri = $res->getUri();
            $this->fedora->getCache()->delete($res);
            $this->fedora->getCache()->add($this);
        }
        return $this;
    }
1231378
public function copyTo($file)
    {
        if (null === $this->file) {
            throw LogicException::create(
                'The update file has not been downloaded.'
            );
        }

        $mode = 0755;

        if (file_exists($file)) {
            $mode = fileperms($file) & 511;
        }

        if (false === @copy($this->file, $file)) {
            throw FileException::lastError();
        }

        if (false === @chmod($file, $mode)) {
            throw FileException::lastError();
        }

        $key = $file . '.pubkey';

        if (file_exists($this->file . '.pubkey')) {
            if (false === @copy($this->file . '.pubkey', $key)) {
                throw FileException::lastError();
            }
        } elseif (file_exists($key)) {
            if (false === @unlink($key)) {
                throw FileException::lastError();
            }
        }
    }
503820
public function offsetSet($offset, $value) {
		$thing = $this->get($offset);
		if (!$thing->isFile() && $thing->isDirectory()) {
			throw  new LogicException("Cannot write to directory.");
		}
		/**
		 * @var File $thing
		 */

		if ($thing->isFile()) {
			$thing->write($value);
		} else {
			$this->createFile($offset, $value);
		}
	}