Touches the given file and ensures the given access permissions are set.

@param string $file
@param int $permissions
@param string The touched file's location.

@throws \RuntimeException When the given file could not be touched.
545630
public static function touchFile(string $file, int $permissions = 0777): string
    {
        self::createDirectory(\dirname($file));
        
        if (!@\touch($file)) {
            throw new \RuntimeException(\sprintf('Unable to touch file "%s"%s', $file, self::getErrorInfo()));
        }
        
        self::changePermissions($file, $permissions);
        
        \clearstatcache(true, $file);
        
        return $file;
    }
514381
public static function start(String $file)
    {
        if( ! Info::available($file) )
        {
            throw new Exception\FileNotFoundException($file);
        }

        self::readFileContent($file);
    }
1320205
public function touch($created = null, $lastAccessed = null) {
		$created = $created instanceof DateTime
			? $created->getTimestamp() 
			: ($created === null ? time() : $created);
		$lastAccessed = $lastAccessed instanceof DateTime
			? $lastAccessed->getTimestamp()
			: ($lastAccessed === null ? time() : $lastAccessed);

		if (!@touch($this->pathname, $created, $lastAccessed)) {
			throw new FileException(sprintf('Failed to touch file at %s', $this->pathname));
		}
	}
171829
public static function delete($file)
	{
		$files = (array) $file;

		foreach ($files as $file)
		{
			$file     = Path::clean($file);
			$filename = basename($file);

			if (!Path::canChmod($file))
			{
				throw new FilesystemException(__METHOD__ . ': Failed deleting inaccessible file ' . $filename);
			}

			// Try making the file writable first. If it's read-only, it can't be deleted
			// on Windows, even if the parent folder is writable
			@chmod($file, 0777);

			// In case of restricted permissions we zap it one way or the other
			// as long as the owner is either the webserver or the ftp
			if (!@ unlink($file))
			{
				throw new FilesystemException(__METHOD__ . ': Failed deleting ' . $filename);
			}
		}

		return true;
	}
666208
public function setPermissionsAttribute($permissions)
    {
        $module = lcfirst($this->attributes['name']);

        $roles = array();

        //prefix the permission with the module name ex: user.create
        foreach ($permissions as $key => $value)
        {
            $roles[] = $module . '.' . $value;
        }

        $this->attributes['permissions'] = ( ! empty($roles)) ? json_encode($roles) : '';
    }
952061
public function hookUserRolePermissions(array &$permissions)
    {
        $permissions['module_file_manager'] = gplcart_text('File manager: access');

        foreach ($this->getHandlers() as $command_id => $command) {
            $permissions["module_file_manager_$command_id"] = gplcart_text('File manager: perform command @name', array(
                '@name' => $command['name']));
        }
    }
814103
public function mkdir($path, $permissions = 0755)
    {
        $writeBinn = new BinnList;

        $writeBinn->addUint8(self::FSERV_MKDIR);
        $writeBinn->addStr($path);
        $writeBinn->addStr($permissions);

        $read = $this->writeAndReadSocket($writeBinn->serialize());

        $readBinn = new BinnList;
        $readBinn->binnOpen($read);
        $results = $readBinn->unserialize();

        if ($results[0] != self::FSERV_STATUS_OK) {
            throw new RuntimeException('Couldn\'t make directory: ' . isset($results[1]) ? $results[1] : 'Unknown');
        }

        return true;
    }
1265403
public static function touch($file, $time = null)
    {
        $touch = $time ? @touch($file, $time) : @touch($file);
        if (true !== $touch) {
            throw new IOException(sprintf("Cannot touch %s", $file));
        }
    }
631744
public static function touch($files, $time = null, $atime = null)
    {
        self::ensureFileSystem()->touch($files, $time, $atime);
    }
464193
public function attach($file = __FILE__)
    {
        if (!file_exists($file)) {
            $touch = touch($file);
            if (!$touch) {
                throw new \RuntimeException("file is not exists and it can not be created. file: {$file}");
            }
        }
        $key = ftok($file, 'a');
        $this->shm = shm_attach($key, $this->size); //allocate shared memory
    }
1014724
public function beforePermission($permissions)
    {
        $permissions = is_array($permissions) ? $permissions : func_get_args();

        $this->beforeFilter(function () use ($permissions) {
            Trusty::filterByPermission($permissions);
        });
    }
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);
        }
    }
985595
public function fileDelete($file)
    {
        foreach ($this->files($file) as $f) {
            if (!unlink($f) && $this->fileExists($f)) {
                throw new RuntimeException(['delete `:file` failed: :last_error_message', 'file' => $f]);
            }
        }
    }
1075508
public function copyToAppliedDir($file)
    {
        if (false === @copy($file->getPathName(), $this->appliedFilesDir . '/' . $file->getFileName())) {
            throw new RuntimeException('cannot copy the sql file to applied directory. check the <info>'. $this->appliedFilesDir . '</info> directory.');
        }
    }
1223042
public static function register(array $permissions): void
    {
        $permissions = self::format($permissions);

        self::$permissions = array_merge(self::$permissions, $permissions);
    }
280039
protected function addResourceFile(string $file): void
    {
        if (!is_file($file)) {
            throw new \InvalidArgumentException("$file is not a file");
        }
        
        $contents = file_get_contents($file);
        
        if ($contents === false) {
            throw new \RuntimeException("Error reading file at $file.");
        }
        
        $this->addResourceString($contents);
    }
1238215
public static function delete($file)
	{
		$files = (array) $file;

		foreach ($files as $file) {
			$file = FileHelper::cleanPath($file);

			// Try making the file writable first. If it's read-only, it can't be deleted
			// on Windows, even if the parent folder is writable
			@chmod($file, 0777);

			// In case of restricted permissions we zap it one way or the other
			// as long as the owner is either the webserver or the ftp
			if (!@ unlink($file)) {
				throw new Exception(__METHOD__ . ': Failed deleting ' . basename($file));
			}
		}

		return true;
	}