2
votes

I'm building an AIR app where some functionality depends on renaming the app executable in the filesystem, and detecting whatever name the executable has when it's launched. I don't need to detect changes while the app is running, if that makes any difference, and I don't need the path or extension — just the name.

If the executable was the only item in its folder, I could get the Application Directory from the File class and go from there. But it would be ideal to have a solution where there may be more than one copy of this AIR executable in a folder, each renamed to something unique.

I've looked at the NativeApplication class, the System class, the File class, and any other class that seems related to this issue, to no avail. The closest I've come is getting the Filename from the Application Descriptor XML, but that only reflects the default name the application is given when published.

So, how I can get the exact current filename of an AIR app at launch?

EDIT: To be more specific, on a Mac this executable would be the .app file, and on Windows this would be the .exe file.

EDIT2: loaderInfo.url won't work — it gives the name of the SWF file running within the AIR app, not the name of the containing AIR app/exe. If you're on a Mac, you can see this SWF file by opening the package contents of the AIR app, and looking in the Resources folder.

1
No idea if this will work (that's why it isn't an answer), but what about Application.application.loaderInfo.url? - cwallenpoole
No, loaderInfo.url gives the name of the SWF file running within the AIR app. If you're on a Mac, you can see this SWF file by opening the package contents of the AIR app, and looking in the Resources folder. This SWF is referenced by the initialWindow property of the Application.xml file, which contains a lot of interesting app settings I hadn't found thus far. But alas, no clues as to the actual, current app filename. But I'm going to keep digging. - ivanreese
@PaulSweatte — Please see the comment directly above yours for the explanation of why that suggestion won't work. - ivanreese

1 Answers

1
votes

Use the following process:

  • Use the class XSLTProcessor, with HTMLLoader if necessary
  • Create an XSLT stylesheet which applied to the <filename> element
  • Apply it to the application descriptor file