make dir if does not exist
This commit is contained in:
		
							parent
							
								
									8c2d3acdec
								
							
						
					
					
						commit
						1d58f51ba4
					
				
					 2 changed files with 25 additions and 13 deletions
				
			
		|  | @ -59,8 +59,8 @@ local function getAllFiles() | |||
| 
 | ||||
|     local result = http.get(indexesUrl) | ||||
|     if result == nil then | ||||
|       print("error! getting indexes for " .. programToInstall) | ||||
|       error() | ||||
|         print("error! getting indexes for " .. programToInstall) | ||||
|         error() | ||||
|     end | ||||
|     local resultText = result.readAll() | ||||
|     local resultTable = split(resultText, "\n") | ||||
|  | @ -85,14 +85,20 @@ local function finishInstall(files) | |||
|     for key, file in ipairs(files) do | ||||
|         if customPath ~= nil then | ||||
|             print("moving " .. file .. " to " .. customPath .. "...") | ||||
|             if not fs.exists(customPath) then | ||||
|                 fs.makeDir(customPath) | ||||
|             end | ||||
|             if fs.exists(customPath .. "/" .. file) then | ||||
|               fs.delete(customPath .. "/" .. file) | ||||
|                 fs.delete(customPath .. "/" .. file) | ||||
|             end | ||||
|             fs.move(temp .. file, customPath .. "/" .. file) | ||||
|         else | ||||
|             print("moving " .. file .. " to " .. path .. programToInstall .. "...") | ||||
|             if not fs.exists(path .. programToInstall) then | ||||
|                 fs.makeDir(path .. programToInstall) | ||||
|             end | ||||
|             if fs.exists(path .. programToInstall .. "/" .. file) then | ||||
|               fs.delete(path .. programToInstall .. "/" .. file) | ||||
|                 fs.delete(path .. programToInstall .. "/" .. file) | ||||
|             end | ||||
|             fs.move(temp .. file, path .. programToInstall .. "/" .. file) | ||||
|         end | ||||
|  | @ -109,9 +115,9 @@ local function finishInstall(files) | |||
| end | ||||
| 
 | ||||
| if not fs.exists(path .. "programs.dat") then | ||||
|   local file = fs.open(path .. "programs.dat", "w") | ||||
|   file.write("") | ||||
|   file.close() | ||||
|     local file = fs.open(path .. "programs.dat", "w") | ||||
|     file.write("") | ||||
|     file.close() | ||||
| end | ||||
| local programsFile = fs.open(path .. "programs.dat", "r") | ||||
| local programsText = programsFile.readAll() | ||||
|  |  | |||
|  | @ -63,16 +63,16 @@ local function getAllFiles() | |||
| 
 | ||||
|     local result = http.post(updateUrl, currentFiles) | ||||
|     if result == nil then | ||||
|       print("error! getting updates for " .. programToInstall) | ||||
|       error() | ||||
|         print("error! getting updates for " .. programToInstall) | ||||
|         error() | ||||
|     end | ||||
|     local resultText = result.readAll() | ||||
|     local resultTable = split(resultText, "\n") | ||||
| 
 | ||||
|     local result2 = http.get(indexesUrl) | ||||
|     if result2 == nil then | ||||
|       print("error! getting indexes for " .. programToInstall) | ||||
|       error() | ||||
|         print("error! getting indexes for " .. programToInstall) | ||||
|         error() | ||||
|     end | ||||
|     local resultText2 = result2.readAll() | ||||
|     local resultTable2 = split(resultText2, "\n") | ||||
|  | @ -102,14 +102,20 @@ local function finishInstall(files) | |||
|     for key, file in ipairs(files) do | ||||
|         if customPath ~= nil then | ||||
|             print("moving " .. file .. " to " .. customPath .. "...") | ||||
|             if not fs.exists(customPath) then | ||||
|                 fs.makeDir(customPath) | ||||
|             end | ||||
|             if fs.exists(customPath .. "/" .. file) then | ||||
|               fs.delete(customPath .. "/" .. file) | ||||
|                 fs.delete(customPath .. "/" .. file) | ||||
|             end | ||||
|             fs.move(temp .. file, customPath .. "/" .. file) | ||||
|         else | ||||
|             print("moving " .. file .. " to " .. path .. programToInstall .. "...") | ||||
|             if not fs.exists(path .. programToInstall) then | ||||
|                 fs.makeDir(path .. programToInstall) | ||||
|             end | ||||
|             if fs.exists(path .. programToInstall .. "/" .. file) then | ||||
|               fs.delete(path .. programToInstall .. "/" .. file) | ||||
|                 fs.delete(path .. programToInstall .. "/" .. file) | ||||
|             end | ||||
|             fs.move(temp .. file, path .. programToInstall .. "/" .. file) | ||||
|         end | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue