Search in sources :

Example 71 with FileHandle

use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.

the class AndroidZipFileHandle method list.

@Override
public FileHandle[] list(FileFilter filter) {
    ZipEntryRO[] zipEntries = expansionFile.getEntriesAt(getPath());
    FileHandle[] handles = new FileHandle[zipEntries.length];
    int count = 0;
    for (int i = 0, n = handles.length; i < n; i++) {
        FileHandle child = new AndroidZipFileHandle(zipEntries[i].mFileName);
        if (!filter.accept(child.file()))
            continue;
        handles[count] = child;
        count++;
    }
    if (count < zipEntries.length) {
        FileHandle[] newHandles = new FileHandle[count];
        System.arraycopy(handles, 0, newHandles, 0, count);
        handles = newHandles;
    }
    return handles;
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) ZipEntryRO(com.badlogic.gdx.backends.android.ZipResourceFile.ZipEntryRO)

Example 72 with FileHandle

use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.

the class AndroidFileHandle method list.

public FileHandle[] list() {
    if (type == FileType.Internal) {
        try {
            String[] relativePaths = assets.list(file.getPath());
            FileHandle[] handles = new FileHandle[relativePaths.length];
            for (int i = 0, n = handles.length; i < n; i++) handles[i] = new AndroidFileHandle(assets, new File(file, relativePaths[i]), type);
            return handles;
        } catch (Exception ex) {
            throw new GdxRuntimeException("Error listing children: " + file + " (" + type + ")", ex);
        }
    }
    return super.list();
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) FileHandle(com.badlogic.gdx.files.FileHandle) File(java.io.File) IOException(java.io.IOException) GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Example 73 with FileHandle

use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.

the class AndroidFileHandle method list.

public FileHandle[] list(FilenameFilter filter) {
    if (type == FileType.Internal) {
        try {
            String[] relativePaths = assets.list(file.getPath());
            FileHandle[] handles = new FileHandle[relativePaths.length];
            int count = 0;
            for (int i = 0, n = handles.length; i < n; i++) {
                String path = relativePaths[i];
                if (!filter.accept(file, path))
                    continue;
                handles[count] = new AndroidFileHandle(assets, new File(file, path), type);
                count++;
            }
            if (count < relativePaths.length) {
                FileHandle[] newHandles = new FileHandle[count];
                System.arraycopy(handles, 0, newHandles, 0, count);
                handles = newHandles;
            }
            return handles;
        } catch (Exception ex) {
            throw new GdxRuntimeException("Error listing children: " + file + " (" + type + ")", ex);
        }
    }
    return super.list(filter);
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) FileHandle(com.badlogic.gdx.files.FileHandle) File(java.io.File) IOException(java.io.IOException) GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Example 74 with FileHandle

use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.

the class AndroidFileHandle method list.

public FileHandle[] list(String suffix) {
    if (type == FileType.Internal) {
        try {
            String[] relativePaths = assets.list(file.getPath());
            FileHandle[] handles = new FileHandle[relativePaths.length];
            int count = 0;
            for (int i = 0, n = handles.length; i < n; i++) {
                String path = relativePaths[i];
                if (!path.endsWith(suffix))
                    continue;
                handles[count] = new AndroidFileHandle(assets, new File(file, path), type);
                count++;
            }
            if (count < relativePaths.length) {
                FileHandle[] newHandles = new FileHandle[count];
                System.arraycopy(handles, 0, newHandles, 0, count);
                handles = newHandles;
            }
            return handles;
        } catch (Exception ex) {
            throw new GdxRuntimeException("Error listing children: " + file + " (" + type + ")", ex);
        }
    }
    return super.list(suffix);
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) FileHandle(com.badlogic.gdx.files.FileHandle) File(java.io.File) IOException(java.io.IOException) GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Example 75 with FileHandle

use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.

the class AndroidFileHandle method list.

public FileHandle[] list(FileFilter filter) {
    if (type == FileType.Internal) {
        try {
            String[] relativePaths = assets.list(file.getPath());
            FileHandle[] handles = new FileHandle[relativePaths.length];
            int count = 0;
            for (int i = 0, n = handles.length; i < n; i++) {
                String path = relativePaths[i];
                FileHandle child = new AndroidFileHandle(assets, new File(file, path), type);
                if (!filter.accept(child.file()))
                    continue;
                handles[count] = child;
                count++;
            }
            if (count < relativePaths.length) {
                FileHandle[] newHandles = new FileHandle[count];
                System.arraycopy(handles, 0, newHandles, 0, count);
                handles = newHandles;
            }
            return handles;
        } catch (Exception ex) {
            throw new GdxRuntimeException("Error listing children: " + file + " (" + type + ")", ex);
        }
    }
    return super.list(filter);
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) FileHandle(com.badlogic.gdx.files.FileHandle) File(java.io.File) IOException(java.io.IOException) GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Aggregations

FileHandle (com.badlogic.gdx.files.FileHandle)79 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)23 IOException (java.io.IOException)22 Array (com.badlogic.gdx.utils.Array)18 File (java.io.File)18 Element (com.badlogic.gdx.utils.XmlReader.Element)9 Texture (com.badlogic.gdx.graphics.Texture)8 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)7 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)7 IntArray (com.badlogic.gdx.utils.IntArray)7 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)6 AssetDescriptor (com.badlogic.gdx.assets.AssetDescriptor)5 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)4 TextureAtlasData (com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData)4 Json (com.badlogic.gdx.utils.Json)4 GwtFileHandle (com.badlogic.gdx.backends.gwt.GwtFileHandle)3 Color (com.badlogic.gdx.graphics.Color)3 InputStream (java.io.InputStream)3 OutputStream (java.io.OutputStream)3 Writer (java.io.Writer)3