Created
August 30, 2013 13:18
-
-
Save MobiDevelop/6389767 to your computer and use it in GitHub Desktop.
LibGDX FileHandleWrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mobidevelop.files; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
import com.badlogic.gdx.files.FileHandle; | |
public class EncryptedFileHandle extends FileHandleWrapper { | |
public EncryptedFileHandle(FileHandle file) { | |
super(file); | |
} | |
public int readBytes(byte[] bytes, int offset, int size) { | |
//TODO: Implement decryption here | |
return super.readBytes(bytes, offset, size); | |
} | |
@Override | |
public byte[] readBytes() { | |
//TODO: Implement decryption here | |
return super.readBytes(); | |
} | |
public InputStream read() { | |
//TODO: Implement decryption here | |
return super.read(); | |
} | |
@Override | |
public OutputStream write(boolean append) { | |
//TODO: Implement encryption here | |
return super.write(append); | |
} | |
@Override | |
public void write(InputStream input, boolean append) { | |
//TODO: Implement encryption here | |
super.write(input, append); | |
} | |
@Override | |
public void writeBytes(byte[] bytes, boolean append) { | |
//TODO: Implement encryption here | |
super.writeBytes(bytes, append); | |
} | |
@Override | |
public void writeBytes(byte[] bytes, int offset, int length, boolean append) { | |
//TODO: Implement encryption here | |
super.writeBytes(bytes, offset, length, append); | |
} | |
@Override | |
public FileHandle child(String name) { | |
return new EncryptedFileHandle(file.child(name)); | |
} | |
@Override | |
public FileHandle sibling(String name) { | |
return new EncryptedFileHandle(file.sibling(name)); | |
} | |
@Override | |
public FileHandle parent() { | |
return new EncryptedFileHandle(file.parent()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mobidevelop.files; | |
import java.io.BufferedInputStream; | |
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
import java.io.Reader; | |
import java.io.Writer; | |
import com.badlogic.gdx.Files.FileType; | |
import com.badlogic.gdx.files.FileHandle; | |
public class FileHandleWrapper extends FileHandle { | |
protected FileHandle file; | |
public FileHandleWrapper(FileHandle file) { | |
this.file = file; | |
} | |
@Override | |
public String path() { | |
return file.path(); | |
} | |
@Override | |
public String name() { | |
return file.name(); | |
} | |
@Override | |
public String extension() { | |
return file.extension(); | |
} | |
@Override | |
public String nameWithoutExtension() { | |
return file.nameWithoutExtension(); | |
} | |
@Override | |
public String pathWithoutExtension() { | |
return file.pathWithoutExtension(); | |
} | |
@Override | |
public FileType type() { | |
return file.type(); | |
} | |
@Override | |
public File file() { | |
return file.file(); | |
} | |
@Override | |
public InputStream read() { | |
return file.read(); | |
} | |
@Override | |
public BufferedInputStream read(int bufferSize) { | |
return file.read(bufferSize); | |
} | |
@Override | |
public Reader reader() { | |
return file.reader(); | |
} | |
@Override | |
public Reader reader(String charset) { | |
return file.reader(charset); | |
} | |
@Override | |
public BufferedReader reader(int bufferSize) { | |
return file.reader(bufferSize); | |
} | |
@Override | |
public BufferedReader reader(int bufferSize, String charset) { | |
return file.reader(bufferSize, charset); | |
} | |
@Override | |
public String readString() { | |
return file.readString(); | |
} | |
@Override | |
public String readString(String charset) { | |
return file.readString(charset); | |
} | |
@Override | |
public byte[] readBytes() { | |
return file.readBytes(); | |
} | |
@Override | |
public int readBytes(byte[] bytes, int offset, int size) { | |
return file.readBytes(bytes, offset, size); | |
} | |
@Override | |
public OutputStream write(boolean append) { | |
return file.write(append); | |
} | |
@Override | |
public void write(InputStream input, boolean append) { | |
file.write(input, append); | |
} | |
@Override | |
public Writer writer(boolean append) { | |
return file.writer(append); | |
} | |
@Override | |
public Writer writer(boolean append, String charset) { | |
return file.writer(append, charset); | |
} | |
@Override | |
public void writeString(String string, boolean append) { | |
file.writeString(string, append); | |
} | |
@Override | |
public void writeString(String string, boolean append, String charset) { | |
file.writeString(string, append, charset); | |
} | |
@Override | |
public void writeBytes(byte[] bytes, boolean append) { | |
file.writeBytes(bytes, append); | |
} | |
@Override | |
public void writeBytes(byte[] bytes, int offset, int length, boolean append) { | |
file.writeBytes(bytes, offset, length, append); | |
} | |
@Override | |
public FileHandle[] list() { | |
return file.list(); | |
} | |
@Override | |
public FileHandle[] list(String suffix) { | |
return file.list(suffix); | |
} | |
@Override | |
public boolean isDirectory() { | |
return file.isDirectory(); | |
} | |
@Override | |
public FileHandle child(String name) { | |
return file.child(name); | |
} | |
@Override | |
public FileHandle sibling(String name) { | |
return file.sibling(name); | |
} | |
@Override | |
public FileHandle parent() { | |
return file.parent(); | |
} | |
@Override | |
public void mkdirs() { | |
file.mkdirs(); | |
} | |
@Override | |
public boolean exists() { | |
return file.exists(); | |
} | |
@Override | |
public boolean delete() { | |
return file.delete(); | |
} | |
@Override | |
public boolean deleteDirectory() { | |
return file.deleteDirectory(); | |
} | |
@Override | |
public void emptyDirectory() { | |
file.emptyDirectory(); | |
} | |
@Override | |
public void emptyDirectory(boolean preserveTree) { | |
file.emptyDirectory(preserveTree); | |
} | |
@Override | |
public void copyTo(FileHandle dest) { | |
file.copyTo(dest); | |
} | |
@Override | |
public void moveTo(FileHandle dest) { | |
file.moveTo(dest); | |
} | |
@Override | |
public long length() { | |
return file.length(); | |
} | |
@Override | |
public long lastModified() { | |
return file.lastModified(); | |
} | |
@Override | |
public String toString() { | |
return file.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment