This repository was archived by the owner on Dec 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -68,13 +68,44 @@ public function getComposerCommand()
68
68
}
69
69
70
70
/**
71
- * Returns true if the path is a "valid" path and is writable (event if the complete path does not yet exist).
71
+ * Returns true if the path is a "valid" path and is writable (even if the complete path does not yet exist).
72
72
* @param string $path
73
73
* @return boolean
74
74
*/
75
75
public function validatePath ($ path )
76
76
{
77
77
$ absPath = $ this ->getAbsolutePath ($ path );
78
+ $ absPathParts = preg_split ('/\// ' , preg_replace ('/(^\/|\/$)/ ' , '' , $ absPath ));
79
+ $ nSteps = count ($ absPath );
80
+
81
+ $ tmpPath = '' ;
82
+ $ prevReadable = false ;
83
+ $ prevWritable = false ;
84
+
85
+ for ($ i =0 ; $ i <$ nSteps ; $ i ++) {
86
+ $ tmpPath .= '/ ' . $ absPathParts [$ i ];
87
+
88
+ if (file_exists ($ tmpPath )) {
89
+ if (!is_dir ($ tmpPath )) {
90
+ if (is_link ($ tmpPath )) {
91
+ $ linkPath = readlink ($ tmpPath );
92
+ if (false === $ linkPath || !is_dir ($ linkPath )) {
93
+ return false ;
94
+ }
95
+ $ tmpPath = $ linkPath ;
96
+ } else {
97
+ return false ;
98
+ }
99
+ }
100
+
101
+ $ prevReadable = is_readable ($ tmpPath );
102
+ $ prevWritable = is_writable ($ tmpPath );
103
+ } else {
104
+ return ($ prevReadable && $ prevWritable );
105
+ }
106
+ }
107
+
108
+ return true ;
78
109
}
79
110
80
111
/**
You can’t perform that action at this time.
0 commit comments