This repository was archived by the owner on Mar 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,11 @@ public function encode() {
99
99
$ zip ->close ();
100
100
101
101
$ profile = base64_encode (file_get_contents ($ temp_zip ));
102
+
103
+ // clean up
104
+ $ this ->deleteDirectory ($ temp_dir );
105
+ unlink ($ temp_zip );
106
+
102
107
return $ profile ;
103
108
}
104
109
@@ -123,6 +128,10 @@ private function installExtension($extension, $profile_dir) {
123
128
mkdir ($ ext_dir , 0777 , true );
124
129
125
130
$ this ->extractTo ($ extension , $ ext_dir );
131
+
132
+ // clean up
133
+ $ this ->deleteDirectory ($ temp_dir );
134
+
126
135
return $ ext_dir ;
127
136
}
128
137
@@ -144,6 +153,24 @@ private function createTempDirectory($prefix = '') {
144
153
return $ temp_dir ;
145
154
}
146
155
156
+ /**
157
+ * @param string $directory The path to the directory.
158
+ */
159
+ private function deleteDirectory ($ directory ) {
160
+ $ dir = new RecursiveDirectoryIterator ($ directory , FilesystemIterator::SKIP_DOTS );
161
+ $ paths = new RecursiveIteratorIterator ($ dir , RecursiveIteratorIterator::CHILD_FIRST );
162
+
163
+ foreach ($ paths as $ path ) {
164
+ if ($ path ->isDir () && !$ path ->isLink ()) {
165
+ rmdir ($ path ->getPathname ());
166
+ } else {
167
+ unlink ($ path ->getPathname ());
168
+ }
169
+ }
170
+
171
+ rmdir ($ directory );
172
+ }
173
+
147
174
/**
148
175
* @param string $xpi The path to the .xpi extension.
149
176
* @param string $target_dir The path to the unzip directory.
You can’t perform that action at this time.
0 commit comments