Search in sources :

Example 1 with TYPFile

use of uk.me.parabola.imgfmt.app.typ.TYPFile in project mkgmap by openstreetmap.

the class TypCompiler method writeTyp.

/**
 * Write the type file out from the compiled form to the given name.
 */
private void writeTyp(TypData data, File file) throws IOException {
    try (FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.READ)) {
        channel.truncate(0);
        FileImgChannel w = new FileImgChannel(channel);
        try (TYPFile typ = new TYPFile(w)) {
            typ.setData(data);
            typ.write();
        }
    }
}
Also used : TYPFile(uk.me.parabola.imgfmt.app.typ.TYPFile) FileChannel(java.nio.channels.FileChannel) FileImgChannel(uk.me.parabola.imgfmt.sys.FileImgChannel)

Example 2 with TYPFile

use of uk.me.parabola.imgfmt.app.typ.TYPFile in project mkgmap by openstreetmap.

the class TypTextReaderTest method testFromFile.

/**
 * Basic test, reading from a file using most features.
 */
@Test
public void testFromFile() throws IOException, InterruptedException {
    Reader r = new BufferedReader(new FileReader("test/resources/typ/test.txt"));
    tr = new TypTextReader();
    tr.read("test.typ", r);
    TestUtils.registerFile("ts__test.typ");
    RandomAccessFile raf = new RandomAccessFile("ts__test.typ", "rw");
    FileChannel channel = raf.getChannel();
    channel.truncate(0);
    try (FileImgChannel w = new FileImgChannel(channel);
        TYPFile typ = new TYPFile(w)) {
        typ.setData(tr.getData());
        typ.write();
    } finally {
        raf.close();
    }
}
Also used : RandomAccessFile(java.io.RandomAccessFile) TYPFile(uk.me.parabola.imgfmt.app.typ.TYPFile) FileChannel(java.nio.channels.FileChannel) BufferedReader(java.io.BufferedReader) SrtTextReader(uk.me.parabola.mkgmap.srt.SrtTextReader) Reader(java.io.Reader) StringReader(java.io.StringReader) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) FileReader(java.io.FileReader) FileImgChannel(uk.me.parabola.imgfmt.sys.FileImgChannel) Test(org.junit.Test)

Aggregations

FileChannel (java.nio.channels.FileChannel)2 TYPFile (uk.me.parabola.imgfmt.app.typ.TYPFile)2 FileImgChannel (uk.me.parabola.imgfmt.sys.FileImgChannel)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 RandomAccessFile (java.io.RandomAccessFile)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 Test (org.junit.Test)1 SrtTextReader (uk.me.parabola.mkgmap.srt.SrtTextReader)1