4 Replies Latest reply on May 23, 2008 11:11 AM by Jeesmon

    Writing read-only files

    maltaannon Level 1
      Hello.

      Ever since first beta version of AIR I knew it is a great opportunity for me to make some of my apps cross-platform. I really love AIR.

      I'm just about to officially release my first AIR app. It works great on Windows, but on Mac I get a small problem, that is (I think) related to "Package directories" or read-only files. There is one XML file that my app have to access and modify in order to complete it's task. It works great on Windows, but on Mac it's just like nothing happened. No error, no nothing.

      I've been through the doc's over and over and found nothing.

      So my question is: is it possible to ignore "read-only" attribute and change the content of the file?
      Or is there a way to change the file attributes, so that it is possible to change the file?

      Thank you.
        • 1. Re: Writing read-only files
          Level 1
          Can you try copying this file to app storage folder from app folder on the first run and modify it there. Modifying files in app folder cause issues even in vista as the "Program Files" is protected. So one option is to check for this file in app storage when app runs and if it is not there copy it from app to app storage, modify it and use it. Will that work for you?
          • 2. Re: Writing read-only files
            maltaannon Level 1
            Let me get this straight. I should locate the XML file that I'm interested in, copy it to my AIR app storage space, modify it there, and then copy it back and overwrite it? This XML file is required by some other application to run, but it is only read when that application starts, and it's not used (locked) by that application, even when it's running.
            • 3. Re: Writing read-only files
              Oliver Goldman Adobe Employee
              No; you should consider the application directory read-only. That means you shouldn't modify or overwrite the files in that location.

              It's not possible to ignore or change the read-only attribute of a file. However, attempting to write to a read-only file will throw an error--not fail silently. I suspect a different issue is causing this problem.

              Oliver Goldman | Adobe AIR Engineering

              • 4. Re: Writing read-only files
                Level 1
                What I meant was to keep the modified file always in the app storage folder. I suggested this option without knowing that another app is consuming the same file. Can you create a symbolic link for the non-air app to use the file from air app storage or change the non-air and air apps to use the file from a common writable folder for both air and non-air apps?