@@ -117,9 +117,11 @@ public function mkdir($dirs, $mode = 0777)
117
117
*/
118
118
public function exists ($ files )
119
119
{
120
+ $ maxPathLength = PHP_MAXPATHLEN - 2 ;
121
+
120
122
foreach ($ this ->toIterator ($ files ) as $ file ) {
121
- if ('\\' === DIRECTORY_SEPARATOR && strlen ($ file ) > 258 ) {
122
- throw new IOException ('Could not check if file exist because path length exceeds 258 characters. ' , 0 , null , $ file );
123
+ if (strlen ($ file ) > $ maxPathLength ) {
124
+ throw new IOException (sprintf ( 'Could not check if file exist because path length exceeds %d characters. ' , $ maxPathLength ) , 0 , null , $ file );
123
125
}
124
126
125
127
if (!file_exists ($ file )) {
@@ -301,8 +303,10 @@ public function rename($origin, $target, $overwrite = false)
301
303
*/
302
304
private function isReadable ($ filename )
303
305
{
304
- if ('\\' === DIRECTORY_SEPARATOR && strlen ($ filename ) > 258 ) {
305
- throw new IOException ('Could not check if file is readable because path length exceeds 258 characters. ' , 0 , null , $ filename );
306
+ $ maxPathLength = PHP_MAXPATHLEN - 2 ;
307
+
308
+ if (strlen ($ filename ) > $ maxPathLength ) {
309
+ throw new IOException (sprintf ('Could not check if file is readable because path length exceeds %d characters. ' , $ maxPathLength ), 0 , null , $ filename );
306
310
}
307
311
308
312
return is_readable ($ filename );
0 commit comments