title: Couldn't load TextureAtlas from zip archive via AssetManager - libgdx
body: <p>I have 2 instances of AssetManager: one for basic textures and one for high quality textures. Basic textures are located in "android/assets" folder and high quality textures are packed in zip file. Content (file names) in this folders are the same - there are only better quality textures in zip archive.</p>
  
  <p>AssetManager throws an exception: "Couldn't load dependencies of asset: teamLogo.png" when I'm trying to load TextureAtlas from zip file. When I'm loading Texture file everything is ok. Loading TextureAtlas works only from 'android/assets' folder.</p>
  
  <p>AssetManager using 'android/assets' - everything is ok:</p>
  
  <pre><code>AssetManager am = new AssetManager();
  am.load( "images/image.png", Texture.class );
  am.load( "images/teamLogo.pack", TextureAtlas.class );
  </code></pre>
  
  <p>AssetManager using zip archive - can't load TextureAtlas:</p>
  
  <pre><code>ZipFile archive = new ZipFile(expansionFileHandle.file());
  ArchiveFileHandleResolver resolver = new ArchiveFileHandleResolver(archive);
  AssetManager amHQ = new AssetManager(resolver);
  </code></pre>
  
  <p>This works fine:</p>
  
  <pre><code>amHQ.load( "images/image.png", Texture.class );
  </code></pre>
  
  <p>This doesn't work:</p>
  
  <pre><code>amHQ.load( "images/teamLogo.pack", TextureAtlas.class );
  </code></pre>
  
  <p>ArchiveFileHandle class:</p>
  
  <pre><code>public class ArchiveFileHandle extends FileHandle 
  { 
  final ZipFile archive;
  final ZipEntry archiveEntry;
  
  public ArchiveFileHandle (ZipFile archive, File file) 
  {
      super(file, FileType.Classpath);
      this.archive = archive;
      archiveEntry = this.archive.getEntry(file.getPath());
  }
  
  public ArchiveFileHandle (ZipFile archive, String fileName) 
  {
      super(fileName.replace('\\', '/'), FileType.Classpath);
      this.archive = archive;
      this.archiveEntry = archive.getEntry(fileName.replace('\\', '/'));
  }
  
  @Override
  public FileHandle child (String name) 
  {
      name = name.replace('\\', '/');
      if (file.getPath().length() == 0) 
          return new ArchiveFileHandle(archive, new File(name));
      return new ArchiveFileHandle(archive, new File(file, name));
  }
  
  @Override
  public FileHandle sibling (String name) 
  {
      name = name.replace('\\', '/');
      if (file.getPath().length() == 0) 
          throw new GdxRuntimeException("Cannot get the sibling of the root.");
      return new ArchiveFileHandle(archive, new File(file.getParent(), name));
  }
  
  @Override
  public FileHandle parent () 
  {
      File parent = file.getParentFile();
      if (parent == null) 
      {
          if (type == FileType.Absolute)
              parent = new File("/");
          else
              parent = new File("");
      }
      return new ArchiveFileHandle(archive, parent);
  }
  
  @Override
  public InputStream read () 
  {
      try 
      {
          return archive.getInputStream(archiveEntry);
      } 
      catch (IOException e) 
      {
          throw new GdxRuntimeException("File not found: " + file + " (Archive)");
      }
  }
  
  @Override
  public boolean exists() 
  {
      return archiveEntry != null;
  }
  
  @Override
  public long length () 
  {
      return archiveEntry.getSize();
  }
  
  @Override
  public long lastModified () 
  {
      return archiveEntry.getTime();
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>