File tree Expand file tree Collapse file tree 1 file changed +0
-36
lines changed Expand file tree Collapse file tree 1 file changed +0
-36
lines changed Original file line number Diff line number Diff line change 192192 return nil , false
193193 end
194194
195- --- @param sourceObject table
196- --- @param targetDirectory string
197- --- @param updateObj table | nil
198- --- @return table | nil
199- --- @return boolean
200- function Net :downloadURL (sourceObject , targetDirectory , updateObj )
201- local sourceName = " default" or (updateObj and updateObj .sourceName )
202- if updateObj then
203- sourceObject .name = sourceObject .name or updateObj .name
204- end
205-
206- if not sourceObject .name then
207- sourceObject .name = self :getNameFromURL (sourceObject .source [sourceName ])
208- end
209- local request = http .get (sourceObject .source [sourceName ])
210-
211- if request then
212- local content = request .readAll ()
213- request .close ()
214-
215- if content then
216- local file = fs .open (targetDirectory .. sourceObject .name , " w" )
217- if not file then
218- os.execute (" mkdir " .. targetDirectory )
219- file = fs .open (targetDirectory .. sourceObject .name , " w" )
220- end
221- file .write (content )
222- file .close ()
223-
224- return sourceObject , true
225- end
226- end
227-
228- return nil , false
229- end
230-
231195 --- @param url string
232196 --- @return string
233197 function Net :getNameFromURL (url )
You can’t perform that action at this time.
0 commit comments