本文整理汇总了PHP中fileinode函数的典型用法代码示例。如果您正苦于以下问题:PHP fileinode函数的具体用法?PHP fileinode怎么用?PHP fileinode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fileinode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listFile
public function listFile($pathname, $pattern = "*")
{
static $_listDirs = array();
$guid = md5($pathname . $pattern);
if (!isset($_listDirs[$guid])) {
$dir = array();
$list = glob($pathname . $pattern);
foreach ($list as $i => $file) {
$dir[$i]["filename"] = preg_replace("/^.+[\\\\\\/]/", "", $file);
$dir[$i]["pathname"] = realpath($file);
$dir[$i]["owner"] = fileowner($file);
$dir[$i]["perms"] = fileperms($file);
$dir[$i]["inode"] = fileinode($file);
$dir[$i]["group"] = filegroup($file);
$dir[$i]["path"] = dirname($file);
$dir[$i]["atime"] = fileatime($file);
$dir[$i]["ctime"] = filectime($file);
$dir[$i]["size"] = filesize($file);
$dir[$i]["type"] = filetype($file);
$dir[$i]["ext"] = is_file($file) ? strtolower(substr(strrchr(basename($file), "."), 1)) : "";
$dir[$i]["mtime"] = filemtime($file);
$dir[$i]["isDir"] = is_dir($file);
$dir[$i]["isFile"] = is_file($file);
$dir[$i]["isLink"] = is_link($file);
$dir[$i]["isReadable"] = is_readable($file);
$dir[$i]["isWritable"] = is_writable($file);
}
$cmp_func = create_function("\$a,\$b", "\r\n\t\t\t\$k = \"isDir\";\r\n\t\t\tif(\$a[\$k] == \$b[\$k]) return 0;\r\n\t\t\treturn \$a[\$k]>\$b[\$k]?-1:1;\r\n\t\t\t");
usort($dir, $cmp_func);
$this->_values = $dir;
$_listDirs[$guid] = $dir;
} else {
$this->_values = $_listDirs[$guid];
}
}
示例2: listFile
public function listFile($pathname, $pattern = '*')
{
static $_listDirs = array();
$guid = md5($pathname . $pattern);
if (!isset($_listDirs[$guid])) {
$dir = array();
$list = glob($pathname . $pattern);
foreach ($list as $i => $file) {
$dir[$i]['filename'] = basename($file);
$dir[$i]['pathname'] = realpath($file);
$dir[$i]['owner'] = fileowner($file);
$dir[$i]['perms'] = fileperms($file);
$dir[$i]['inode'] = fileinode($file);
$dir[$i]['group'] = filegroup($file);
$dir[$i]['path'] = dirname($file);
$dir[$i]['atime'] = fileatime($file);
$dir[$i]['ctime'] = filectime($file);
$dir[$i]['size'] = filesize($file);
$dir[$i]['type'] = filetype($file);
$dir[$i]['ext'] = is_file($file) ? strtolower(substr(strrchr(basename($file), '.'), 1)) : '';
$dir[$i]['mtime'] = filemtime($file);
$dir[$i]['isDir'] = is_dir($file);
$dir[$i]['isFile'] = is_file($file);
$dir[$i]['isLink'] = is_link($file);
$dir[$i]['isReadable'] = is_readable($file);
$dir[$i]['isWritable'] = is_writable($file);
}
$cmp_func = create_function('$a,$b', '' . "\r\n" . ' $k = "isDir";' . "\r\n" . ' if($a[$k] == $b[$k]) return 0;' . "\r\n" . ' return $a[$k]>$b[$k]?-1:1;' . "\r\n" . ' ');
usort($dir, $cmp_func);
$this->_values = $dir;
$_listDirs[$guid] = $dir;
} else {
$this->_values = $_listDirs[$guid];
}
}
示例3: dir2array
function dir2array($dir, $content)
{
if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
if (!is_dir($dir)) {
return array();
}
$dir_handle = opendir($dir);
$array = array();
while ($object = readdir($dir_handle)) {
if (!in_array($object, array('.', '..'))) {
$filepath = $dir . $object;
$file_object = array('name' => $object, 'path' => $dir, 'size' => filesize($filepath), 'type' => filetype($filepath), 'node' => fileinode($filepath), 'group' => filegroup($filepath), 'time' => getTime($filepath), 'perms' => getPermissions($filepath));
if ($file_object['type'] == 'dir') {
if ($content == true) {
$file_object['content'] = dir2array($filepath, $content);
}
} else {
if ($content == true) {
$file_object['content'] = file2base64($filepath);
}
$file_object['mime'] = getMime($filepath);
}
$array[] = $file_object;
}
}
return $array;
}
示例4: __construct
public function __construct($file, $scope = self::SCOPE_APP, $size = 65535)
{
$mf = $file . ($scope == self::SCOPE_PID) ? '.' . getmypid() : '';
if (!file_exists($mf)) {
touch($mf);
}
$this->key = fileinode($mf);
$this->debug("SHM key: %d", $this->key);
$this->shm = shm_attach($this->key, $size, 0700);
}
示例5: servicemain
function servicemain()
{
for ($s = 0; $s < 5; $s++) {
usleep(100000);
$key = fileinode(__FILE__);
$this->enterCriticalSection($key);
echo $this->char;
$this->leaveCriticalSection();
}
}
示例6: __construct
/**
* 构造函数
* @throws \Exception
*/
private function __construct()
{
// 主配置位置
$config_file = WORKERMAN_ROOT_DIR . '/conf/workerman.conf';
if (!file_exists($config_file)) {
throw new \Exception('Configuration file "' . $config_file . '" not found');
}
// 载入主配置
self::$config['workerman'] = self::parseFile($config_file);
self::$config['workerman']['log_dir'] = isset(self::$config['workerman']['log_dir']) ? self::$config['workerman']['log_dir'] : WORKERMAN_ROOT_DIR . '/logs';
self::$configFile = realpath($config_file);
// 寻找应用配置
$conf_d = isset(self::$config['workerman']['include']) ? self::$config['workerman']['include'] : self::DEFAULT_CONFD_PATH;
$index = 1;
foreach (glob($conf_d) as $config_file) {
$worker_name = basename($config_file, '.conf');
$config_data = self::parseFile($config_file);
if (isset(self::$config[$worker_name])) {
$worker_name = $worker_name . '-' . $index++;
}
if (!isset($config_data['enable']) || $config_data['enable']) {
self::$config[$worker_name] = self::parseFile($config_file);
} else {
continue;
}
// 支持 WORKERMAN_ROOT_DIR 配置
array_walk_recursive(self::$config[$worker_name], array('\\Man\\Core\\Lib\\Config', 'replaceWORKERMAN_ROOT_DIR'));
// 找出绝对路径
$config_file = realpath($config_file);
if (self::$config[$worker_name]['worker_file'][0] !== '/') {
self::$config[$worker_name]['worker_file'] = dirname($config_file) . '/' . self::$config[$worker_name]['worker_file'];
}
if (!isset(self::$config[$worker_name]['chdir'])) {
self::$config[$worker_name]['chdir'] = dirname($config_file);
}
}
// 整理Monitor配置
self::$config['Monitor'] = self::$config['workerman']['Monitor'];
unset(self::$config['workerman']['Monitor']);
self::$config['Monitor']['worker_file'] = '../Common/Monitor.php';
self::$config['Monitor']['persistent_connection'] = 1;
self::$config['Monitor']['start_workers'] = 1;
self::$config['Monitor']['user'] = 'root';
self::$config['Monitor']['preread_length'] = 8192;
self::$config['Monitor']['exclude_path'] = isset(self::$config['Monitor']['exclude_path']) ? array_merge(self::$config['Monitor']['exclude_path'], get_included_files()) : get_included_files();
self::$config['Monitor']['exclude_path'][] = self::$config['workerman']['log_dir'];
self::$config['Monitor']['exclude_path'][] = sys_get_temp_dir();
if (!isset(self::$config['Monitor']['listen'])) {
$socket_file = '/tmp/workerman.' . fileinode(__FILE__) . '.sock';
self::$config['Monitor']['listen'] = 'unix://' . $socket_file;
}
// 支持 WORKERMAN_ROOT_DIR 配置
array_walk_recursive(self::$config['Monitor'], array('\\Man\\Core\\Lib\\Config', 'replaceWORKERMAN_ROOT_DIR'));
}
示例7: createFile
/**
* Creates a new file in the directory
*
* Data will either be supplied as a stream resource, or in certain cases
* as a string. Keep in mind that you may have to support either.
*
* After successful creation of the file, you may choose to return the ETag
* of the new file here.
*
* The returned ETag must be surrounded by double-quotes (The quotes should
* be part of the actual string).
*
* If you cannot accurately determine the ETag, you should not return it.
* If you don't store the file exactly as-is (you're transforming it
* somehow) you should also not return an ETag.
*
* This means that if a subsequent GET to this new file does not exactly
* return the same contents of what was submitted here, you are strongly
* recommended to omit the ETag.
*
* @param string $name Name of the file
* @param resource|string $data Initial payload
* @return null|string
*/
function createFile($name, $data = null)
{
// We're not allowing dots
if ($name == '.' || $name == '..') {
throw new DAV\Exception\Forbidden('Permission denied to . and ..');
}
$newPath = $this->path . '/' . $name;
file_put_contents($newPath, $data);
clearstatcache(true, $newPath);
return '"' . sha1(fileinode($newPath) . filesize($newPath) . filemtime($newPath)) . '"';
}
示例8: testPut
function testPut()
{
$request = new HTTP\Request('PUT', '/testput.txt');
$filename = $this->tempDir . '/testput.txt';
$request->setBody('Testing new file');
$this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals(['X-Sabre-Version' => [DAV\Version::VERSION], 'Content-Length' => ['0'], 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"']], $this->response->getHeaders());
$this->assertEquals(201, $this->response->status);
$this->assertEquals('', $this->response->body);
$this->assertEquals('Testing new file', file_get_contents($filename));
}
示例9: getFileInfo
public static function getFileInfo($path)
{
$aryFileInfo = array();
$aryFileInfo["accessed"] = fileatime($path);
$aryFileInfo["changed"] = filectime($path);
$aryFileInfo["group"] = filegroup($path);
$aryFileInfo["inode"] = fileinode($path);
$aryFileInfo["modified"] = filemtime($path);
$aryFileInfo["owner"] = fileowner($path);
$aryFileInfo["permissions"] = fileperms($path);
$aryFileInfo["size"] = filesize($path);
return $aryFileInfo;
}
示例10: testBaseUri
function testBaseUri()
{
$serverVars = ['REQUEST_URI' => '/blabla/test.txt', 'REQUEST_METHOD' => 'GET'];
$filename = $this->tempDir . '/test.txt';
$request = HTTP\Sapi::createFromServerArray($serverVars);
$this->server->setBaseUri('/blabla/');
$this->assertEquals('/blabla/', $this->server->getBaseUri());
$this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals(['X-Sabre-Version' => [Version::VERSION], 'Content-Type' => ['application/octet-stream'], 'Content-Length' => [13], 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($filename)))], 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"']], $this->response->getHeaders());
$this->assertEquals(200, $this->response->status);
$this->assertEquals('Test contents', stream_get_contents($this->response->body));
}
示例11: generateKey
public static function generateKey($file = null)
{
if (!$file) {
if (!empty($argv[0])) {
$file = $argv[0];
} elseif (!empty($_SERVER["SCRIPT_FILENAME"])) {
$file = $_SERVER["SCRIPT_FILENAME"];
} else {
$file = tempnam(null, "ipc");
}
}
$key = fileinode($file);
return $key;
}
示例12: parseConfig
/**
* Checks if the commit it's possible and parse arguments
* Checks if repository, group and user_name are right.
* It extract group from svnroot, and check if the plugin
* is availabe. It checks if the user exists.
*
* @param array $Config Config
*
* @return array Returns 'check'=true if check passed, group, group_id
*/
function parseConfig(&$Config)
{
global $sys_svnroot_path, $svn_tracker_debug, $file;
$Result = array();
$Result['check'] = true;
$Repository = $Config['Repository'];
$UserName = $Config['UserName'];
if ($sys_svnroot_path[strlen($sys_svnroot_path) - 1] != '/') {
$sys_svnroot_path .= '/';
}
$repo_root = substr($Repository, 0, strrpos($Repository, "/") + 1);
//we get the directory of the repository root (with trailing slash)
if (fileinode($sys_svnroot_path) == fileinode($repo_root)) {
// since the $sys_svnroot_path is usually $sys_svnroot, and that one is a symlink, we check that the inode is the same for both
$GroupName = substr($Repository, strrpos($Repository, "/") + 1);
$Config['FileName'] = substr($Config['FileName'], strlen($Repository));
//get only the filename relative to the repo
} else {
$GroupName = $Repository;
$Config['FileName'] = $Config['FileName'];
}
if ($svn_tracker_debug) {
echo "GroupName = " . $GroupName . "\n";
echo "SVNRootPath = " . $sys_svnroot_path . "\n";
}
if ($svn_tracker_debug) {
fwrite($file, $GroupName . "\n");
}
$Result['group'] = group_get_object_by_name($GroupName);
$Result['user'] = user_get_object_by_name($UserName);
if (!$Result['group'] || !is_object($Result['group']) || $Result['group']->isError() || !$Result['group']->isActive()) {
$Result['check'] = false;
$Result['error'] = 'Group Not Found';
} else {
$Result['group_id'] = $Result['group']->getID();
if (!$Result['group']->usesPlugin('svntracker')) {
$Result['check'] = false;
$Result['error'] = 'Plugin not enabled for this Group';
}
}
if (!$Result['user'] || !is_object($Result['user']) || $Result['user']->isError() || !$Result['user']->isActive()) {
$Result['check'] = false;
$Result['error'] = 'Invalid User';
}
return $Result;
}
示例13: __construct
public function __construct($file, $scope = self::SCOPE_GLOBAL, $size = 65535)
{
if (!$file) {
throw new \BadArgumentException("Expected filename to Queue constructor");
}
$mf = $file . ($scope == self::SCOPE_PID ? '.' . getmypid() : '');
if (!file_exists($mf)) {
touch($mf);
}
$this->key = fileinode($mf);
if (!msg_queue_exists($this->key)) {
debug("Creating IPC queue (0x%x) for %s", $this->key, $mf);
$this->queue = msg_get_queue($this->key, 0600);
} else {
debug("Reopening IPC queue (0x%x) for %s", $this->key, $mf);
$this->queue = msg_get_queue($this->key, 0600);
}
}
示例14: listFile
/**
+----------------------------------------------------------
* 取得目录下面的文件信息
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param mixed $pathname 路径
+----------------------------------------------------------
*/
function listFile($pathname, $pattern = '*')
{
static $_listDirs = array();
$guid = md5($pathname . $pattern);
if (!isset($_listDirs[$guid])) {
$dir = array();
$list = glob($pathname . $pattern);
foreach ($list as $i => $file) {
//$dir[$i]['filename'] = basename($file);
//basename取中文名出问题.改用此方法
//编码转换.把中文的调整一下.
$dir[$i]['filename'] = preg_replace('/^.+[\\\\\\/]/', '', $file);
$dir[$i]['pathname'] = realpath($file);
$dir[$i]['owner'] = fileowner($file);
$dir[$i]['perms'] = fileperms($file);
$dir[$i]['inode'] = fileinode($file);
$dir[$i]['group'] = filegroup($file);
$dir[$i]['path'] = dirname($file);
$dir[$i]['atime'] = fileatime($file);
$dir[$i]['ctime'] = filectime($file);
$dir[$i]['size'] = filesize($file);
$dir[$i]['type'] = filetype($file);
$dir[$i]['ext'] = is_file($file) ? strtolower(substr(strrchr(basename($file), '.'), 1)) : '';
$dir[$i]['mtime'] = filemtime($file);
$dir[$i]['isDir'] = is_dir($file);
$dir[$i]['isFile'] = is_file($file);
$dir[$i]['isLink'] = is_link($file);
//$dir[$i]['isExecutable']= function_exists('is_executable')?is_executable($file):'';
$dir[$i]['isReadable'] = is_readable($file);
$dir[$i]['isWritable'] = is_writable($file);
}
$cmp_func = create_function('$a,$b', '
$k = "isDir";
if($a[$k] == $b[$k]) return 0;
return $a[$k]>$b[$k]?-1:1;
');
// 对结果排序 保证目录在前面
usort($dir, $cmp_func);
$this->_values = $dir;
$_listDirs[$guid] = $dir;
} else {
$this->_values = $_listDirs[$guid];
}
}
示例15: getfilename_with_inodelist
function getfilename_with_inodelist($file_dir, $attach_list)
{
$result = array();
$i = 0;
$dir_hd = @opendir($file_dir) or die("can't open:{$file_dir}");
while (($file = readdir($dir_hd)) !== false) {
if (is_dir($file)) {
// dir
} else {
$file = $file_dir . "/" . $file;
$file_inode = fileinode($file);
foreach ($attach_list as $item) {
if ($item == $file_inode) {
$result[] = $file;
break;
}
}
}
}
return $result;
}