Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: get hidden/archive/system porps on file #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/Native/NativeFileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public function getMTime(): int {
*
* Since the unix mask doesn't contain the proper hidden/archive/system flags we have to assume them
* as false (except for `hidden` where we use the unix dotfile convention)
*
* But on file, unix mask contain the proper hidden/archive/system flags with transfer.
* hidden -> o+x, archive -> u+x, system -> g+x,
* refer: https://gitlab.com/samba-team/samba/-/blob/84b5440eb4f3c10e2729e916d097f5af07150dcd/source3/libsmb/libsmb_stat.c#L67
*/

protected function getMode(): int {
Expand Down Expand Up @@ -117,7 +121,11 @@ public function isReadOnly(): bool {
public function isHidden(): bool {
$mode = $this->getMode();
if ($mode > 0x1000) {
return strlen($this->name) > 0 && $this->name[0] === '.';
if ($mode & 0x4000) { // is directory
return strlen($this->name) > 0 && $this->name[0] === '.';
} else {
return (bool)($mode & 0x1); // 0x01: hidden -> o+x
}
} else {
return (bool)($mode & IFileInfo::MODE_HIDDEN);
}
Expand All @@ -126,7 +134,11 @@ public function isHidden(): bool {
public function isSystem(): bool {
$mode = $this->getMode();
if ($mode > 0x1000) {
return false;
if ($mode & 0x4000) { // is directory
return false;
} else {
return (bool)($mode & 0x8); // 0x08: system -> g+x
}
} else {
return (bool)($mode & IFileInfo::MODE_SYSTEM);
}
Expand All @@ -135,7 +147,11 @@ public function isSystem(): bool {
public function isArchived(): bool {
$mode = $this->getMode();
if ($mode > 0x1000) {
return false;
if ($mode & 0x4000) { // is directory
return false;
} else {
return (bool)($mode & 0x40); // 0x40: archive -> u+x
}
} else {
return (bool)($mode & IFileInfo::MODE_ARCHIVE);
}
Expand Down