Search in sources :

Example 6 with TFile

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;
}
Also used : TFile(net.java.truevfs.access.TFile)

Example 7 with TFile

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());
    }
}
Also used : TFile(net.java.truevfs.access.TFile) TFileWriter(net.java.truevfs.access.TFileWriter) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) TFileReader(net.java.truevfs.access.TFileReader) Writer(java.io.Writer) TFileWriter(net.java.truevfs.access.TFileWriter) Test(org.junit.Test)

Example 8 with TFile

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"));
}
Also used : TFile(net.java.truevfs.access.TFile) Test(org.junit.Test)

Example 9 with TFile

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();
}
Also used : TFile(net.java.truevfs.access.TFile)

Example 10 with TFile

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;
}
Also used : TFile(net.java.truevfs.access.TFile) BufferedImage(java.awt.image.BufferedImage)

Aggregations

TFile (net.java.truevfs.access.TFile)14 BufferedImage (java.awt.image.BufferedImage)4 IOException (java.io.IOException)2 Test (org.junit.Test)2 BufferedReader (java.io.BufferedReader)1 Writer (java.io.Writer)1 AccessDeniedException (java.nio.file.AccessDeniedException)1 Matcher (java.util.regex.Matcher)1 CardInfo (mage.cards.repository.CardInfo)1 TFileOutputStream (net.java.truevfs.access.TFileOutputStream)1 TFileReader (net.java.truevfs.access.TFileReader)1 TFileWriter (net.java.truevfs.access.TFileWriter)1 FsSyncException (net.java.truevfs.kernel.spec.FsSyncException)1 CardDownloadData (org.mage.plugins.card.images.CardDownloadData)1