use of net.java.truevfs.access.TFile in project mage by magefree.
the class CardImageUtils method getTokenImagePath.
private static String getTokenImagePath(CardDownloadData card) {
String filename = buildImagePathToCard(card);
TFile file = new TFile(filename);
if (!file.exists()) {
String tokenDescriptorfilename = generateTokenDescriptorImagePath(card);
if (!tokenDescriptorfilename.isEmpty()) {
file = new TFile(filename);
if (file.exists()) {
return tokenDescriptorfilename;
}
}
}
return filename;
}
use of net.java.truevfs.access.TFile in project mage by magefree.
the class ZipFilesReadWriteTest method test_write.
@Test
public void test_write() {
try {
String zipPath = tempFolder.newFolder().getAbsolutePath();
TFile fileWriteZip = new TFile(Paths.get(zipPath, "temp-images.zip", "DIR", "test.txt").toString());
Assert.assertFalse(fileWriteZip.exists());
Writer writer = new TFileWriter(fileWriteZip);
try {
writer.write("test text");
writer.close();
Assert.assertTrue(fileWriteZip.exists());
TFileReader reader = new TFileReader(fileWriteZip);
BufferedReader br = new BufferedReader(reader);
Assert.assertEquals(br.readLine(), "test text");
reader.close();
} finally {
TVFS.umount();
}
} catch (IOException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of net.java.truevfs.access.TFile in project mage by magefree.
the class ZipFilesReadWriteTest method test_Read.
@Test
public void test_Read() {
// exists
TFile fileZip = new TFile(Paths.get("src", "test", "data", "images.zip").toString());
Assert.assertTrue(fileZip.exists());
TFile fileZipDir = new TFile(Paths.get("src", "test", "data", "images.zip", "SET").toString());
Assert.assertTrue(fileZipDir.exists());
TFile fileZipFile = new TFile(Paths.get("src", "test", "data", "images.zip", "SET", "image1.png").toString());
Assert.assertTrue(fileZipFile.exists());
// not exists
TFile fileNotZip = new TFile(Paths.get("src", "test", "data", "images-FAIL.zip").toString());
Assert.assertFalse(fileNotZip.exists());
TFile fileNotZipDir = new TFile(Paths.get("src", "test", "data", "images.zip", "SET-FAIL").toString());
Assert.assertFalse(fileNotZipDir.exists());
TFile fileNotZipFile = new TFile(Paths.get("src", "test", "data", "images.zip", "SET", "image1-FAIL.png").toString());
Assert.assertFalse(fileNotZipFile.exists());
// reading
Assert.assertEquals(3, fileZipDir.list().length);
Assert.assertTrue(Arrays.asList(fileZipDir.list()).contains("image1.png"));
Assert.assertTrue(Arrays.asList(fileZipDir.list()).contains("image2.png"));
Assert.assertTrue(Arrays.asList(fileZipDir.list()).contains("image3.png"));
}
use of net.java.truevfs.access.TFile in project mage by magefree.
the class ImageCache method isFaceImagePresent.
public static boolean isFaceImagePresent(CardView card) {
String path;
path = CardImageUtils.generateFaceImagePath(card.getName(), card.getExpansionSetCode());
if (path == null) {
return false;
}
TFile file = getTFile(path);
if (file == null) {
return false;
}
return file.exists();
}
use of net.java.truevfs.access.TFile in project mage by magefree.
the class ImageCache method getMorphImage.
public static BufferedImage getMorphImage() {
// TODO: replace by morth image
CardDownloadData info = new CardDownloadData("Morph", "KTK", "0", false, 0, "KTK", "");
info.setToken(true);
String path = CardImageUtils.generateTokenImagePath(info);
if (path == null) {
return null;
}
TFile file = getTFile(path);
BufferedImage image = loadImage(file);
image = getRoundCorner(image);
return image;
}
Aggregations