Mac style .app loader for Windows - Archive problems
Posted: Fri Jan 04, 2013 10:30 am
So I finally broke down and posted something on here. I could only do so much with so little information before I needed to ask.
I am currently working on a small-ish program that opens .app filetypes in Windows. These files are basically zipped files that are loaded into temporary location and they all have an "AppInfo" pointing to the location of the executable. It worked flawlessly when I tested with a "Drag & Drop" system (the .app file is dropped onto a small un-decorated stack and is launched. A stand-alone VLC Player program launched in a matter of seconds using this system), but I wanted it to handle command-line parameters so I can set an "Open with application" rule. The program does launch now when I double-click any .app file and handles it to a point, but now it just freezes when opening the archive. It can't even progress past that point in the code. My code is beginning to become a bit of a mess since I have tried just about every arrangement I could think of to get this to work and even borrowed some sample code (which has been thoroughly mangled by now). Adding waits did nothing. It just sticks is all.
If you read the code, you will see that I added an "answer "opening archive"" command. This is where the code stops working.
This was one of my bright ideas to make Windows a little simpler, but now it is just becoming a headache. I was initially hoping of making Mac-style executable folders for programs to reduce them to one file (easier to handle and all), but there's no such thing in Windows as far as I can tell, so archives are the next best thing, aside from the ugly temporary files business.
Here's the code I am testing... If it makes any sense.
EDIT: THIS CODE IS OLD NOW. NEWER CODE AND SAMPLE .REV IS IN LATER POST.
I would love it if anyone has any solution to my archive failing to open and the code getting trapped there. Also, I would like it if there was a simpler way of clearing the "tmp" folder other than deleting it and re-creating it every time an app is launched. Obviously, this is only able to handle one app at a time for now, but it wouldn't be too difficult to make it delete the temporary files only on exit.
Of course, if you know of any way I can make folders executable by this program as though they were files, that would be awesome to know.
On a side note, I have another program that is to run as a miniature portable Windows wrapper that looks like a separate OS. It works great (including a lovely registry hijack for some Windows system settings that are reset afterward), aside from the fact that the background stack keeps not staying on the background (i.e. it likes to cover things instead of staying behind them). I researched everywhere for a solution to this problem, including third party solutions, but there's nothing to be found.
I am currently working on a small-ish program that opens .app filetypes in Windows. These files are basically zipped files that are loaded into temporary location and they all have an "AppInfo" pointing to the location of the executable. It worked flawlessly when I tested with a "Drag & Drop" system (the .app file is dropped onto a small un-decorated stack and is launched. A stand-alone VLC Player program launched in a matter of seconds using this system), but I wanted it to handle command-line parameters so I can set an "Open with application" rule. The program does launch now when I double-click any .app file and handles it to a point, but now it just freezes when opening the archive. It can't even progress past that point in the code. My code is beginning to become a bit of a mess since I have tried just about every arrangement I could think of to get this to work and even borrowed some sample code (which has been thoroughly mangled by now). Adding waits did nothing. It just sticks is all.
If you read the code, you will see that I added an "answer "opening archive"" command. This is where the code stops working.
This was one of my bright ideas to make Windows a little simpler, but now it is just becoming a headache. I was initially hoping of making Mac-style executable folders for programs to reduce them to one file (easier to handle and all), but there's no such thing in Windows as far as I can tell, so archives are the next best thing, aside from the ugly temporary files business.
Here's the code I am testing... If it makes any sense.
EDIT: THIS CODE IS OLD NOW. NEWER CODE AND SAMPLE .REV IS IN LATER POST.
Code: Select all
local tStartApp = ""
local tLocation = ""
local tAppInfo = ""
local tFolder = ""
on startup
put $1 into tStartApp
end startup
on openstack
prep
end openstack
on prep
local tZipContents
if the environment is not "development" then
if tStartApp is "" then
answer "No paramaters sent. Nothing to load."
lock messages
quit
end if
end if
set the shellcommand to "C:\Windows\System32\cmd.exe"
clearFileList
wait 200 milliseconds with messages
revdeletefolder "C:\Users\[user]\Desktop\tmp"
new folder "C:\Users\[user]\Desktop\tmp"
put "C:\Users\[user]\Desktop\tmp" into tFolder
answer "opening archive" ------------------------------------------------------------------------------------------
revZipOpenArchive tStartApp,"read"
if the result is "ziperr" then
answer "An error occurred."
lock messages
quit
end if
put revZipEnumerateItems(tStartApp) into tZipContents
put tZipContents into field "FileList"
revZipCloseArchive tStartApp
extractArchive tStartApp, "C:\Users\[user]\Desktop\tmp"
end prep
on clearFileList
put empty into field "FileList"
end clearFileList
on ensureFolder pFolder
if there is a folder pFolder or pFolder is empty then
exit ensureFolder
end if
set the itemDel to "/"
ensureFolder item 1 to -2 of pFolder
create folder pFolder
end ensureFolder
on extractArchive pArchive, pWhere
local tName
local tAppLocation
set the itemDel to "/"
put pWhere into tLocation
if char -1 of tLocation is not "/" then
put "/" after tLocation
end if
put char 1 to -5 of item -1 of pArchive after tLocation
set the itemDel to "."
if there is a folder tLocation then
local tCount
put 1 into tCount
put "." & tCount after tLocation
repeat until there is no folder tLocation
add 1 to tCount
put tCount into item -1 of tLocation
end repeat
end if
set the itemDel to comma
revZipOpenArchive pArchive, "read"
repeat for each line tItem in field "FileList"
if char -1 of tItem is "/" then
else if item 6 of revZipDescribeItem(pArchive,tItem) is "deflate" then
set the itemDel to "/"
ensureFolder tLocation & "/" & item 1 to -2 of tItem
set the itemDel to ","
revZipExtractItemToFile pArchive, tItem, tLocation & "/" & tItem
end if
end repeat
revZipCloseArchive pArchive
set itemdelimiter to "/"
put the last item of tStartApp into tName
set itemdelimiter to "."
put the first item of tName into tName
wait for 200 milliseconds with messages
open file "C:\Users\[user]\Desktop\tmp\" & tName & "\AppInfo"
read from file "C:\Users\[user]\Desktop\tmp\" & tName & "\AppInfo" until return
put it into tAppInfo
if tAppInfo is "" then answer "AppInfo file not found!"
close file "C:\Users\[user]\Desktop\tmp\" & tName & "\AppInfo"
put "C:\Users\[user]\Desktop\tmp\" & tName & "\" & tAppInfo into tAppLocation
wait for 200 milliseconds with messages
get shell (tAppLocation)
wait 200 milliseconds with messages
quit
end extractArchive
Of course, if you know of any way I can make folders executable by this program as though they were files, that would be awesome to know.
On a side note, I have another program that is to run as a miniature portable Windows wrapper that looks like a separate OS. It works great (including a lovely registry hijack for some Windows system settings that are reset afterward), aside from the fact that the background stack keeps not staying on the background (i.e. it likes to cover things instead of staying behind them). I researched everywhere for a solution to this problem, including third party solutions, but there's nothing to be found.