本文整理汇总了PHP中linkinfo函数的典型用法代码示例。如果您正苦于以下问题:PHP linkinfo函数的具体用法?PHP linkinfo怎么用?PHP linkinfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了linkinfo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: truepath
/**
* This function is to replace PHP's extremely buggy realpath().
* @param string The original path, can be relative etc.
* @return string The resolved path, it might not exist.
*/
function truepath($path)
{
// whether $path is unix or not
$unipath = strlen($path) == 0 || $path[0] != '/';
// attempts to detect if path is relative in which case, add cwd
if (strpos($path, ':') === false && $unipath) {
$path = getcwd() . DIRECTORY_SEPARATOR . $path;
}
// resolve path parts (single dot, double dot and double delimiters)
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
$absolutes = array();
foreach ($parts as $part) {
if ('.' == $part) {
continue;
}
if ('..' == $part) {
array_pop($absolutes);
} else {
$absolutes[] = $part;
}
}
$path = implode(DIRECTORY_SEPARATOR, $absolutes);
// resolve any symlinks
if (file_exists($path) && linkinfo($path) > 0) {
$path = readlink($path);
}
// put initial separator that could have been lost
$path = !$unipath ? '/' . $path : $path;
return $path;
}
示例2: linkinfo
echo "*** Testing linkinfo() and is_link() on deleted link ***\n";
// link name used here
$linkname = "{$file_path}/symlink_link_linkinfo_is_link_link_variation5.tmp";
// create temp dir
$dirname = "{$file_path}/symlink_link_linkinfo_is_link_variation5";
mkdir($dirname);
// filename used here
$filename = "{$dirname}/symlink_link_linkinfo_is_link_variation5.tmp";
// create the file
$fp = fopen($filename, "w");
$data = "Hello World";
fwrite($fp, $data);
fclose($fp);
var_dump(symlink($filename, $linkname));
// create link
// delete the link
var_dump(unlink($linkname));
// delete the link
// clear the cache
clearstatcache();
// try using linkinfo() & is_link() on deleted link; expected: false
$deleted_link = $linkname;
var_dump(linkinfo($deleted_link));
var_dump(is_link($deleted_link));
echo "Done\n";
error_reporting(0);
$file_path = dirname(__FILE__);
$dirname = "{$file_path}/symlink_link_linkinfo_is_link_variation5";
$filename = "{$dirname}/symlink_link_linkinfo_is_link_variation5.tmp";
unlink($filename);
rmdir($dirname);
示例3: symlink
echo "*** Testing symlink() for error conditions ***\n";
//zero arguments
var_dump(symlink());
//more than expected
var_dump(symlink($filename, $linkname, true));
//invalid arguments
var_dump(symlink(NULL, $linkname));
// NULL as filename
var_dump(symlink('', $linkname));
// empty string as filename
var_dump(symlink(false, $linkname));
// boolean false as filename
var_dump(symlink($filename, NULL));
// NULL as linkname
var_dump(symlink($filename, ''));
// '' as linkname
var_dump(symlink($filename, false));
// false as linkname
echo "\n*** Testing linkinfo() for error conditions ***\n";
//zero arguments
var_dump(linkinfo());
//more than expected
var_dump(linkinfo($linkname, true));
//invalid arguments
var_dump(linkinfo(NULL));
// NULL as linkname
var_dump(linkinfo(''));
// empty string as linkname
var_dump(linkinfo(false));
// boolean false as linkname
echo "Done\n";
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_standard_tests_file_symlink_link_linkinfo_is_link_error1.php
示例4: unlink
// delete the link created
unlink($obj->linkname);
// clear the cache
clearstatcache();
echo "\n*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members of an array ***\n";
$link_arr = array("{$dirname}/symlink_link_linkinfo_is_link_link.tmp");
/* Testing on soft links */
echo "\n-- Working with soft links --\n";
// creating soft link
var_dump(symlink($filename, $link_arr[0]));
// check if the link exist
var_dump(linkinfo($link_arr[0]));
// check if link is soft link
var_dump(is_link($link_arr[0]));
// delete the link created
unlink($link_arr[0]);
// clear the cache
clearstatcache();
/* Testing on hard links */
echo "\n-- Working with hard links --\n";
// creating hard link
var_dump(link($filename, $link_arr[0]));
// check if the link exist
var_dump(linkinfo($link_arr[0]));
// check if link is soft link; expected: false as this is a hardlink
var_dump(is_link($link_arr[0]));
// delete the links created
unlink($link_arr[0]);
// clear the cache
clearstatcache();
echo "Done\n";
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_standard_tests_file_symlink_link_linkinfo_is_link_variation1.php
示例5: _linkPublicHtmlFolder
protected function _linkPublicHtmlFolder()
{
if (!empty($this->options['public_html'])) {
if (function_exists('symlink')) {
$this->options['public_html'] = $this->getAbsolutePath($this->options['public_html']);
$link_info = @linkinfo($this->options['public_html']);
$target = $this->options['directory'] . DS . 'public';
if ($target == $this->options['public_html']) {
// No need to symlink, same path on target
return true;
}
if (!is_numeric($link_info) || $link_info < 0) {
$this->yield("\n Adding symbolic link " . $this->options['public_html'] . ' to the public web server.');
if (@symlink($target, $this->options['public_html'])) {
return true;
}
}
}
$this->yield("\n Could not create a symbolic link of " . $this->options['directory'] . DS . 'public' . ' at ' . $this->options['public_html']);
}
return false;
}
示例6: create
/**
* Create a link.
*
* @access public
* @param string $name Link name.
* @param string $target Target name.
* @return bool
*/
public static function create($name, $target)
{
if (false != linkinfo($name)) {
return true;
}
return symlink($target, $name);
}
示例7: linkinfo
$linkinfo = linkinfo($hard_link);
$s1 = lstat($hard_link);
echo "linkinfo() returns : {$linkinfo}\n";
echo "lstat() returns lstat['dev'] as {$s1['0']}\n";
if ($s1[0] == $linkinfo) {
echo "\nlinkinfo() value matches lstat['dev']\n";
} else {
echo "\nWarning: linkinfo() value doesnt match lstat['dev']\n";
}
// delete link
unlink($hard_link);
echo "\n*** Checking lstat() on a soft link to directory ***\n";
// create soft link
var_dump(symlink($dirname, $soft_link));
// confirming that linkinfo() = lstat['dev'], this should always match
$linkinfo = linkinfo($soft_link);
$s1 = lstat($soft_link);
echo "linkinfo() returns : {$linkinfo}\n";
echo "lstat() returns lstat['dev'] as {$s1['0']}\n";
if ($s1[0] == $linkinfo) {
echo "\nlinkinfo() value matches lstat['dev']\n";
} else {
echo "\nWarning: linkinfo() value doesnt match lstat['dev']\n";
}
// delete link
unlink($soft_link);
echo "Done\n";
error_reporting(0);
$file_path = dirname(__FILE__);
$dirname = $file_path . "/symlink_link_linkinfo_is_link_variation9";
$filename = "{$dirname}/symlink_link_linkinfo_is_link_variation9.tmp";
示例8: notInstalled
/**
* @brief get a list of themes that are not yet installed
*
* @access public
*
* @return array list of themes that are not installed
*/
public function notInstalled()
{
App::uses('InstallerLib', 'Installer.Lib');
$installed = $this->installed();
$notInstalled = array();
foreach (InfinitasPlugin::listPlugins('loaded') as $plugin) {
foreach (InstallerLib::findThemes($plugin) as $theme) {
if (!array_key_exists($theme, $installed)) {
$notInstalled[$plugin . '.' . $theme] = Inflector::humanize(Inflector::underscore($plugin . Inflector::camelize($theme)));
}
}
}
foreach (InstallerLib::findThemes() as $theme) {
if (!linkinfo(InstallerLib::themePath(null, $theme)) && !array_key_exists($theme, $installed)) {
$notInstalled[$theme] = Inflector::humanize(Inflector::underscore($theme));
}
}
return $notInstalled;
}
示例9: absolutePath
public function absolutePath($path)
{
$isEmptyPath = strlen($path) == 0;
$isRelativePath = $path[0] != '/';
$isWindowsPath = !(strpos($path, ':') === false);
if (($isEmptyPath || $isRelativePath) && !$isWindowsPath) {
$path = getcwd() . DIRECTORY_SEPARATOR . $path;
}
// resolve path parts (single dot, double dot and double delimiters)
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
$pathParts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
$absolutePathParts = array();
foreach ($pathParts as $part) {
if ($part == '.') {
continue;
}
if ($part == '..') {
array_pop($absolutePathParts);
} else {
$absolutePathParts[] = $part;
}
}
$path = implode(DIRECTORY_SEPARATOR, $absolutePathParts);
// resolve any symlinks
if (file_exists($path) && linkinfo($path) > 0) {
$path = readlink($path);
}
// put initial separator that could have been lost
$path = !$isWindowsPath ? '/' . $path : $path;
return $path;
}
示例10: dirname
<?php
$filename = dirname(__FILE__) . "/symlink.dat";
$link = dirname(__FILE__) . "/symlink.link";
var_dump(symlink($filename, $link));
var_dump(readlink($link));
var_dump(linkinfo($link));
@unlink($link);
var_dump(readlink($link));
var_dump(linkinfo($link));
touch($filename);
var_dump(symlink($filename, dirname(__FILE__)));
@unlink($link);
var_dump(symlink($filename, $link));
@unlink($link);
touch($link);
var_dump(symlink($filename, $link));
@unlink($link);
var_dump(link($filename, $link));
@unlink($filename);
var_dump(link($filename, $link));
@unlink($link);
var_dump(symlink(".", "."));
var_dump(link(".", "."));
var_dump(readlink("."));
var_dump(linkinfo("."));
echo "Done\n";
示例11: linkinfo
/**
* Gets information about a link
*
* @param string $path Path to the link.
*
* @return int
*/
public function linkinfo(string $path) : int
{
return linkinfo($path);
}
示例12: getAbsolutePath
public static function getAbsolutePath($path, $default = null)
{
// Get the normalized oldPath, return the $default value if failed
if (($path = self::getNormalizedPath($path)) === null) {
return $default;
}
// Try to get the real oldPath using PHPs function, return the result if succeed
if (($realPath = realpath($path)) !== false) {
return $realPath;
}
// Try to make the oldPath absolute without any system functions
// Check whether the oldPath is in unix format or not
$isUnixPath = empty($path) || $path[0] != '/';
// Detect whether the oldPath is relative, if so prefix the current working directory
if (strpos($path, ':') === false && $isUnixPath) {
$path = getcwd() . DIRECTORY_SEPARATOR . $path;
}
// Put initial separator that could have been lost
$path = !$isUnixPath ? '/' . $path : $path;
// Resolve any symlinks
if (file_exists($path) && linkinfo($path) > 0) {
$path = readlink($path);
}
// Return the result
return $path;
}
示例13: var_dump
var_dump(file_put_contents($path1, 'data'));
var_dump(file($path1));
var_dump(readfile($path1));
var_dump(parse_ini_file($path1));
var_dump(md5_file($path1));
var_dump(sha1_file($path1));
var_dump(fileperms($path1));
var_dump(fileinode($path1));
var_dump(filesize($path1));
var_dump(fileowner($path1));
var_dump(filegroup($path1));
var_dump(fileatime($path1));
var_dump(filemtime($path1));
var_dump(filectime($path1));
var_dump(filetype($path1));
var_dump(linkinfo($path1));
var_dump(is_writable($path1));
var_dump(is_writeable($path1));
var_dump(is_readable($path1));
var_dump(is_executable($path1));
var_dump(is_file($path1));
var_dump(is_dir($path1));
var_dump(is_link($path1));
var_dump(file_exists($path1));
var_dump(stat($path1));
var_dump(lstat($path1));
var_dump(realpath($path1));
var_dump(disk_free_space($path1));
var_dump(diskfreespace($path1));
var_dump(disk_total_space($path1));
var_dump(chmod($path1, '644'));
示例14: urlencode
}
echo $A, '</font></a></td><td><a href="?action=dir&dir=', $SCDIR, '&dirname=', urlencode($dir[$dirFILE]), '">INFO</a></td></tr>';
}
foreach ($Files as $dirFILE) {
if (is_link($dir[$dirFILE])) {
/*display links*/
++$L;
echo '<tr onmouseover="this.style.backgroundColor=\'#8B0000\';" onmouseout="this.style.backgroundColor=\'\';"><td><table class="NoPad" style="margin-left:-2px;"><tr><td><img src="?action=img&image=link" width="16" height="16" alt="SymLink" /></td><td>';
$L = readlink($dir[$dirFILE]);
if (is_dir($dir[$dirFILE])) {
echo '<a href="?dir=', urlencode(realpath($dir[$dirFILE])), '">[', $dir[$dirFILE], ']';
} else {
echo '<a href="?action=file&file=', realpath($L), '">', $dir[$dirFILE];
}
echo '</a></td></tr></table></td><td>LINK -> ', $L;
if (linkinfo($L) != -1) {
echo ' <font color="green">[Exists]</font>';
} else {
echo ' <font color="red">[Exists]</font>';
}
echo '</td><td>', date('F d Y H:i:s.', filemtime($dir[$dirFILE])), '</td><td>';
$A = filegroup($dir[$dirFILE]);
$B = fileowner($dir[$dirFILE]);
echo $B;
if (function_exists('posix_getpwuid')) {
$PwUID = posix_getpwuid($B);
echo ' (', $PwUID['name'], ')';
}
echo '/', $A;
if (function_exists('posix_getgrgid')) {
$PwGID = posix_getgrgid($A);
示例15: exists
/**
* Check whether the symbolic link exists.
*
* @param SymbolicLink|string $link Symbolic link instance or the symbolic link path as a string.
*
* @return bool True if the symbolic link exists, false otherwise.
* False will be returned if the path of the symbolic link is invalid.
*/
public static function exists($link)
{
// Convert the link into a path string, return the $default value if failed
if (($link = self::asPath($link, false)) === null) {
return false;
}
// Get the symbolic link info and check whether the link exists, return the result
$info = linkinfo($link);
return $info !== 0 && $info !== false;
}