views:

1395

answers:

2

I've found several examples and documentation that show how to read and write files on the system, but all show user intervention or reading/writing files in user profile directories. There are a few things I want to do:

  1. Monitor system and other application log files for changes, then automatically load those files when changes occur
  2. Reload a previously open file when the application launches
  3. Write files into a log directory, which probably will not exist in the same path as the application.

In my very quick search, it seems that there may be a security model that constrains an AIR application's access to the file system, so that files can only be read or written to directories selected by the user with the file system dialog OR files can be written within the user profile or air application directory.

Does an Adobe Air application have unconstrained access to the file system?

+1  A: 

I would say your answer depends on the platform. I'm sure that Adobe Air does not automatically have root access on OS X, so it would not be able to read, write and execute in cases where whatever owner started the AIR app did not have the right permissions for accessing a file. In short, you probably have the same privileges any other program running on the computer might have that was installed by the same user.

More information here:

http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7f05.html#WS5b3ccc516d4fbf351e63e3d118666ade46-7e35

apphacker
Access does not depend on the installer, only on the current user.
Johan Öbrink
Ah, but it isn't the install running as the current user?
apphacker
Yes but I have seen cases where the install is done by IT department with full access but the program is then run by the user with limited access.
Johan Öbrink
+2  A: 

AIR has exactly the same access to the file system as the current User. If you are admin on your computer, AIR har full access to all files. If you are a restricted user, AIR has restricted access.

One thing to be mindful of is that if you load swf:s from the AIR app's home directory, it will be run in the Application sandbox. If you read it from outside, it will be executed within a File sandbox which is essentially the same as loading from the web.

Some comments on your list:

1 Monitor system and other application log files for changes, then automatically load those files when changes occur

As far as I know, AIR cannot monitor the file system. You will have to poll this regularly.

2 Reload a previously open file when the application launches

Save this info in a file or SQLite and check it when the app starts.

3 Write files into a log directory, which probably will not exist in the same path as the application.

The main thing to remember is to use the file path abstractions in AIR rather than OS specific paths such as c:/

Johan Öbrink