title: Adobe AIR and different OS filesystems
body: <p>Another Adobe Air question for you but first here some background into the project I have been tasked with.  It is an AIR app that will read assets from a USB key and must work on both WIN and MacOS.  The problem is, how do I load assets into the app on MacOS!  Sounds simple enough and works seamlessly on Windows.</p>
  
  <p>Here is a code snippet of what i am trying to do:</p>
  
  <pre><code>            var loader:Loader = new Loader(); 
              loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ok);
              loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
  
              var p:String;
  
              if (os == "mac")
              {
                  p = "/Volumes/" + keyVolume.rootDirectory.name + File.separator + "0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg";
              }
              else
              {
                  p = keyVolume.rootDirectory.name + File.separator + "0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg";
              }
  
              var temp:File = new File(p);
              Debugger.Display.text += "\nAttempting to load: " + p;
              Debugger.Display.text += "\nDoes it exist? " + temp.exists;
              loader.load(new URLRequest(p));
  </code></pre>
  
  <p>... the variable OS and keyVolume are being successfully set in earlier code.  Also, I have the event listener callbacks defined as well for ok() and ioErro().</p>
  
  <p>When this is run it prints out on windows:</p>
  
  <p>Attempting to load: G:\0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg<br>
  Does it exist: true</p>
  
  <p>... and then successfully loads the asset.</p>
  
  <p>On MacOS, it prints out:</p>
  
  <p>Attempting to load: /Volumes/AC/0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg<br>
  Does it exist: true</p>
  
  <p>... and then fails with an IOError every time.</p>
  
  <p>Can anyone see something that I am missing here?  Do I have some sort of permission error or something (file has "read / write" access).  The USB key is formatted in MS-DOS FAT32, could that be a problem?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I formatted a new USB key in MacOS to FAT16 and put the files onto it with no success.  Problems remain.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am now just trying to load an asset from /users/-USERNAME-/Desktop and still am receiving the same error, so it looks like it isn't a permissions issue on just the USB stick, it is more widespread than that.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>PROBLEM SOLVED!  I finally worded my Google search correctly and it <a href="http://forums.adobe.com/thread/701762?tstart=0" rel="nofollow">revealed the answer</a>.</p>
  
  <p>These changes will fix the problem:</p>
  
  <pre><code>            var loader:Loader = new Loader(); 
              loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ok);
              loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
  
              var p:String = keyVolume.rootDirectory.nativePath + ((os == "mac") ? File.separator : "") + "0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg";
              var temp:File = new File(p);
              Debugger.Display.text += "\nAttempting to load: " + temp.url;
              Debugger.Display.text += "\nDoes it exist? " + temp.exists;
              loader.load(new URLRequest(temp.url));
  </code></pre>
  
  <p>I have also refined the logical statement involving the OS detection a bit as well.</p>
  
  <p>I hope someone finds this useful!</p>