Search in sources :

Example 1 with FamilyXmlWriter

use of net.sourceforge.usbdm.deviceEditor.peripherals.FamilyXmlWriter in project usbdm-eclipse-plugins by podonoghue.

the class TestParseXML method main.

public static void main(String[] args) throws Exception {
    Path directory = Paths.get("");
    // Locate data output directory
    Path outputDirectory = directory.resolve("hardware2");
    // Create output directories if needed
    if (!outputDirectory.toFile().exists()) {
        Files.createDirectory(outputDirectory);
    }
    DirectoryStream<Path> folderStream = Files.newDirectoryStream(directory.resolve("hardware").toAbsolutePath(), sourceFilter);
    for (Path filePath : folderStream) {
        if (!Files.isRegularFile(filePath)) {
            continue;
        }
        /*
          * Process each input file
          */
        System.err.println("Processing " + filePath.getFileName() + " ======================== ");
        DeviceInfo deviceInfo = DeviceInfo.create(filePath);
        // report(deviceInfo);
        Path xmlFilePath = outputDirectory.resolve(filePath.getFileName());
        FamilyXmlWriter writer = new FamilyXmlWriter(deviceInfo);
        writer.writeXmlFile(xmlFilePath);
    }
}
Also used : Path(java.nio.file.Path) FamilyXmlWriter(net.sourceforge.usbdm.deviceEditor.peripherals.FamilyXmlWriter) DeviceInfo(net.sourceforge.usbdm.deviceEditor.information.DeviceInfo)

Example 2 with FamilyXmlWriter

use of net.sourceforge.usbdm.deviceEditor.peripherals.FamilyXmlWriter in project usbdm-eclipse-plugins by podonoghue.

the class CreateHardwareFiles method main.

public static void main(String[] args) throws Exception {
    Path directory = Paths.get("");
    // Locate data output directory
    Path xmlDirectory = directory.resolve("hardware");
    // Create output directories if needed
    if (!xmlDirectory.toFile().exists()) {
        Files.createDirectory(xmlDirectory);
    }
    // Path to data folder - csv files describing the device
    DirectoryStream<Path> folderStream = Files.newDirectoryStream(directory.resolve("data").toAbsolutePath(), sourceFilter);
    for (Path filePath : folderStream) {
        if (!Files.isRegularFile(filePath)) {
            continue;
        }
        /*
          * Process each input file
          */
        System.err.println("Processing " + filePath.getFileName() + " ======================== ");
        String sourceName = filePath.getFileName().toString();
        String destinationName = sourceName.replaceAll("(^.*)" + Pattern.quote(DeviceInfo.HARDWARE_CSV_FILE_EXTENSION) + "$", "$1" + DeviceInfo.HARDWARE_FILE_EXTENSION);
        DeviceInfo deviceInfo = DeviceInfo.create(filePath);
        Path xmlFilePath = xmlDirectory.resolve(destinationName);
        FamilyXmlWriter writer = new FamilyXmlWriter(deviceInfo);
        writer.writeXmlFile(xmlFilePath);
    }
}
Also used : Path(java.nio.file.Path) FamilyXmlWriter(net.sourceforge.usbdm.deviceEditor.peripherals.FamilyXmlWriter) DeviceInfo(net.sourceforge.usbdm.deviceEditor.information.DeviceInfo)

Aggregations

Path (java.nio.file.Path)2 DeviceInfo (net.sourceforge.usbdm.deviceEditor.information.DeviceInfo)2 FamilyXmlWriter (net.sourceforge.usbdm.deviceEditor.peripherals.FamilyXmlWriter)2