gpt4 book ai didi

PHP:识别 Windows 上的连接点 (PHP5/Apache 2.4)

转载 作者:可可西里 更新时间:2023-11-01 10:44:34 25 4
gpt4 key购买 nike

有什么方法可以识别文件夹是否是 Windows 系统上 PHP 中的连接点?甚至获取目标的路径/名称?

is_linkrealpath 不支持。

谢谢!

最佳答案

是的,通过使用lstat(),参见http://php.net/manual/de/function.lstat.php

它返回一个数组,其中包含有关文件名(目录/连接)的信息片段。您需要将键 mode 与某个位掩码进行比较。

mode 等于底层 OS 层中的 st_mode_stat 结构在 SYS\STAT.H 中定义。它包含一个字段 st_mode

关于st_mode 位掩码:

Bit mask for file-mode information. The _S_IFDIR bit is set if path specifies a directory; the _S_IFREG bit is set if path specifies an ordinary file or a device. User read/write bits are set according to the file's permission mode; user execute bits are set according to the filename extension.

     * #define  _S_IFDIR    0x4000
* #define _S_IFREG 0x8000

引自:https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions?view=vs-2017


isJunction() 的 PHP 实现:https://github.com/composer/composer/blob/master/src/Composer/Util/Filesystem.php#L654-L678

警告 在对 Windows 进行最新更改后,这非常脆弱。参见 https://www.bountysource.com/issues/53997655-composer-update-is-deleting-pathed-windows-symlinked-local-repos-again-ref-4955

关于PHP:识别 Windows 上的连接点 (PHP5/Apache 2.4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31695209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com