Unlink a file

@param string $file
@return void
@throws Exception\RuntimeException
962884
protected function unlink($file)
    {
        ErrorHandler::start();
        $res = unlink($file);
        $err = ErrorHandler::stop();

        // only throw exception if file still exists after deleting
        if (!$res && file_exists($file)) {
            throw new Exception\RuntimeException(
                "Error unlinking file '{$file}'; file still exists", 0, $err
            );
        }
    }
187999
protected function _unlink($path) {
		
		$newkey = $this->_normpath($path);
		$newkey = preg_replace("/\/$/", "", $newkey);

		try {
			$obj = $this->s3->DeleteObject(array('Bucket' => $this->options['bucket'], 'Key' => $newkey));
		} catch (Exception $e) {
		
		}
		
		/*$fp = fopen('/tmp/eltest.txt','a+');
		
		fwrite($fp, 'key='.$newkey);*/
		
		if (is_object($obj)) {
			//fwrite($fp, 'obj='.var_export($obj,true));
			
			if (isset($obj->DeleteObjectResponse->Code)) {
				$rc = $obj->DeleteObjectResponse->Code;
				
				if (substr($rc, 0, 1) == '2') {
					return true;
				}
			}
		}

			
		//fclose($fp);
		
		return false;
	}
633985
public function unlink($url)
  {
    $partition = self::getPartition($url);
    $path = self::getRelativePath($url);

    return !!$partition->deleteFile($path);
  }
1309464
public static function Delete( string $file )
   {

      if ( ! \file_exists( $file ) )
      {
         // No deleting required
         return;
      }

      try
      {
         \unlink( $file );
         \clearstatcache();
         if ( ! \file_exists( $file ) )
         {
            // Deleting was successfull
            return;
         }
      }
      catch ( \Throwable $ex ) { }

      if ( static::IS_WIN )
      {
         $f = \escapeshellarg( $file );
         try { \exec( "del {$f}" ); }
         catch ( \Throwable $ex )
         {
            throw new IOError( 'IO', $file, 'Deleting the defined file fails!', \E_USER_ERROR, $ex );
         }
         \clearstatcache();
         if ( \file_exists( $file ) )
         {
            throw new IOError( 'IO', $file, 'Deleting the defined file fails! No known method works.' );
         }
         return;
      }

      try { \exec( "unlink {$file}" ); }
      catch ( \Throwable $ex )
      {
         throw new IOError( 'IO', $file, 'Deleting the defined file fails!', \E_USER_ERROR, $ex );
      }

      \clearstatcache();

      if ( \file_exists( $file ) )
      {
         throw new IOError( 'IO', $file, 'Deleting the defined file fails!' );
      }

   }
938292
public function remove( $key ) {
		if ( ! $this->enabled ) {
			return false;
		}

		$filename = $this->filename( $key );

		if ( file_exists( $filename ) ) {
			return unlink( $filename );
		}

		return false;
	}
181766
public static function rmfile($file)
    {
        if (is_file($file)) {
            return chmod($file, 0777) && unlink($file);
        } else {
            throw new RuntimeException(sprintf(
                'Invalid file path supplied "%s"', $file
            ));
        }
    }
200863
public function remove($key) {
    $path = $this->getFileName($key, TRUE);
    if (file_exists($path)) {
      unlink($path);
    }
  }
680010
public static function removeFile($file)
    {
        if (!is_readable($file) || !is_file($file)) {
            throw new Exception('No such file: ' . $file);
        }
        $res = unlink($file);
        if (false === $res) {
            throw new Exception('File deleting failure: ' . $file);
        }
        return $res;
    }
1360131
public function remove($files)
    {
        if ($files instanceof \Traversable) {
            $files = iterator_to_array($files, false);
        } elseif (!is_array($files)) {
            $files = array($files);
        }
        $files = array_reverse($files);
        foreach ($files as $file) {
            if (is_link($file)) {
                // See https://bugs.php.net/52176
                if (!(self::box('unlink', $file) || '\\' !== DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
                    throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, self::$lastError));
                }
            } elseif (is_dir($file)) {
                $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));

                if (!self::box('rmdir', $file) && file_exists($file)) {
                    throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, self::$lastError));
                }
            } elseif (!self::box('unlink', $file) && file_exists($file)) {
                throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, self::$lastError));
            }
        }
    }
1165985
public static function removeFile(string $file)
    {
        // Copied from [[removeDirectory()]]
        try {
            unlink($file);
        } catch (ErrorException $e) {
            if (DIRECTORY_SEPARATOR === '\\') {
                // last resort measure for Windows
                $lines = [];
                exec("DEL /F/Q \"$file\"", $lines, $deleteError);
            } else {
                throw $e;
            }
        }
    }
331419
public function rollbackMigration($file)
    {
        $migration = $this->getMigrationObjectByFileName($file);

        $this->checkTransactionAndRun($migration, function () use ($migration, $file) {
            if ($migration->down() === false) {
                throw new Exception("<error>Can't rollback migration:</error> {$file}.php");
            }
        });

        $this->removeSuccessfulMigrationFromLog($file);
    }
869282
private function removeFiles()
    {
        foreach ($this->files as $filename) {
            if (file_exists($filename)) {
                @unlink($filename);
            }
        }
        $this->files = array();
    }
530495
public function removeFile($file) {
		if(!is_array($file)) {
			$file = func_get_args();
		}
		$this->begin();
		foreach($file as $item) {
			$this->run('git rm', $item, '-r');
		}
		return $this->end();
	}
40687
static function Unlink($file,&$error = null,&$error_str = null){
		$error = false;
		$error_str = "";

		if(!file_exists($file)){
			return 0;
		}

		$stat = unlink($file);

		if(!$stat){
			$error = true;
			$error_str = "cannot unlink $file";
			return 0;
		}

		return 1;
	}
927400
private function removePath(string $path): void
    {
        if (false !== strpos($path, '*')) {
            $paths = glob($path);
            foreach ($paths as $path) {
                $this->removePath($path);
            }
        } else {
            if (is_dir($path)) {
                $iterator = new \RecursiveDirectoryIterator($path);
                $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST);
                /** @var \SplFileInfo $file */
                foreach ($iterator as $file) {
                    if ('.' === $file->getBasename() || '..' === $file->getBasename()) {
                        continue;
                    }
                    if ($file->isLink() || $file->isFile()) {
                        unlink($file->getPathname());
                    } else {
                        rmdir($file->getPathname());
                    }
                }
                rmdir($path);
            } else {
                if (is_file($path)) {
                    unlink($path);
                }
            }
        }
    }
917836
public function up($file)
    {
        if (false === ($contents = file_get_contents($file->getPathName()))) {
            throw new RuntimeException($file->getPathName() . ' is not found.');
        }
        $queries = explode(';', $contents);
        try {
            $dbh = $this->pdo->connection(true);
            $dbh->beginTransaction();
            foreach($queries as $query) {
                $cleanedQuery = trim($query);
                if ('' === $cleanedQuery) {
                    continue;
                }
                $stmt = $dbh->prepare($cleanedQuery);
                $stmt->execute();
            }
            $dbh->commit();
        } catch(\PDOException $e) {
            $dbh->rollBack();
            throw new RuntimeException($e->getMessage() . PHP_EOL . $query);
        }

        $this->copyToAppliedDir($file);
    }
2144
public static function fromConfigFile($file)
	{
		if(!is_file($file))
		{
			throw new \RuntimeException(sprintf('Config file "%s" does not exist', $file));
		}
		
		$config = new Configuration(static::processConfigFileData(require $file));
		
		return new ConnectionManager($config->getConfig('ConnectionManager'));
	}