@@ -85,6 +85,10 @@ public function getMTime(): int {
85
85
*
86
86
* Since the unix mask doesn't contain the proper hidden/archive/system flags we have to assume them
87
87
* as false (except for `hidden` where we use the unix dotfile convention)
88
+ *
89
+ * But on file, unix mask contain the proper hidden/archive/system flags with transfer.
90
+ * hidden -> o+x, archive -> u+x, system -> g+x,
91
+ * refer: https://gitlab.com/samba-team/samba/-/blob/84b5440eb4f3c10e2729e916d097f5af07150dcd/source3/libsmb/libsmb_stat.c#L67
88
92
*/
89
93
90
94
protected function getMode (): int {
@@ -117,7 +121,11 @@ public function isReadOnly(): bool {
117
121
public function isHidden (): bool {
118
122
$ mode = $ this ->getMode ();
119
123
if ($ mode > 0x1000 ) {
120
- return strlen ($ this ->name ) > 0 && $ this ->name [0 ] === '. ' ;
124
+ if ($ mode & 0x4000 ) { // is directory
125
+ return strlen ($ this ->name ) > 0 && $ this ->name [0 ] === '. ' ;
126
+ } else {
127
+ return (bool )($ mode & 0x1 ); // 0x01: hidden -> o+x
128
+ }
121
129
} else {
122
130
return (bool )($ mode & IFileInfo::MODE_HIDDEN );
123
131
}
@@ -126,7 +134,11 @@ public function isHidden(): bool {
126
134
public function isSystem (): bool {
127
135
$ mode = $ this ->getMode ();
128
136
if ($ mode > 0x1000 ) {
129
- return false ;
137
+ if ($ mode & 0x4000 ) { // is directory
138
+ return false ;
139
+ } else {
140
+ return (bool )($ mode & 0x8 ); // 0x08: system -> g+x
141
+ }
130
142
} else {
131
143
return (bool )($ mode & IFileInfo::MODE_SYSTEM );
132
144
}
@@ -135,7 +147,11 @@ public function isSystem(): bool {
135
147
public function isArchived (): bool {
136
148
$ mode = $ this ->getMode ();
137
149
if ($ mode > 0x1000 ) {
138
- return false ;
150
+ if ($ mode & 0x4000 ) { // is directory
151
+ return false ;
152
+ } else {
153
+ return (bool )($ mode & 0x40 ); // 0x40: archive -> u+x
154
+ }
139
155
} else {
140
156
return (bool )($ mode & IFileInfo::MODE_ARCHIVE );
141
157
}
0 commit comments