Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New autocoder employing XML definition file format
Signed-off-by: Chris Jackson <chris@cd-jackson.com>
- Loading branch information
Showing
601 changed files
with
108,283 additions
and
19,153 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ bin/ | |
*.log | ||
*.log.* | ||
*.json | ||
*.sh | ||
*.zip | ||
.metadata | ||
local.properties | ||
|
||
|
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
90 changes: 0 additions & 90 deletions
90
...ms.zigbee.autocode/src/main/java/com/zsmartsystems/zigbee/autocode/CodeGeneratorUtil.java
This file was deleted.
Oops, something went wrong.
108 changes: 108 additions & 0 deletions
108
...martsystems.zigbee.autocode/src/main/java/com/zsmartsystems/zigbee/autocode/FileCopy.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/** | ||
* Copyright (c) 2016-2019 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package com.zsmartsystems.zigbee.autocode; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
|
||
/** | ||
* Utility class to compare to files and copy if they are different | ||
* | ||
* @author Chris Jackson | ||
* | ||
*/ | ||
public class FileCopy { | ||
private boolean fileCompare(String file1, String file2) throws IOException { | ||
File f = new File(file1); | ||
if (!f.exists()) { | ||
return false; | ||
} | ||
f = new File(file2); | ||
if (!f.exists()) { | ||
return false; | ||
} | ||
|
||
BufferedReader reader1 = new BufferedReader(new FileReader(file1)); | ||
BufferedReader reader2 = new BufferedReader(new FileReader(file2)); | ||
|
||
String line1 = reader1.readLine(); | ||
String line2 = reader2.readLine(); | ||
|
||
boolean areEqual = true; | ||
|
||
int lineNum = 1; | ||
|
||
while (line1 != null || line2 != null) { | ||
if (line1 == null || line2 == null) { | ||
areEqual = false; | ||
|
||
break; | ||
} else if (!line1.startsWith("@Generated") && !line1.equalsIgnoreCase(line2)) { | ||
areEqual = false; | ||
|
||
break; | ||
} | ||
|
||
line1 = reader1.readLine(); | ||
line2 = reader2.readLine(); | ||
|
||
lineNum++; | ||
} | ||
|
||
if (areEqual) { | ||
System.out.println("Two files have same content."); | ||
} else { | ||
System.out.println("Two files have different content. They differ at line " + lineNum); | ||
System.out.println("File1 has " + line1 + " and File2 has " + line2 + " at line " + lineNum); | ||
} | ||
|
||
reader1.close(); | ||
reader2.close(); | ||
|
||
return areEqual; | ||
} | ||
|
||
private void copyFile(String source, String dest) throws IOException { | ||
File target = new File(dest); | ||
|
||
File parent = target.getParentFile(); | ||
if (!parent.exists() && !parent.mkdirs()) { | ||
throw new IllegalStateException("Couldn't create dir: " + parent); | ||
} | ||
|
||
if (target.exists()) { | ||
Files.delete(new File(dest).toPath()); | ||
} | ||
|
||
Files.copy(new File(source).toPath(), new File(dest).toPath()); | ||
} | ||
|
||
public void compareFiles(String inFolder, String outFolder, String folder) { | ||
File[] files = new File(inFolder + folder).listFiles(); | ||
for (File file : files) { | ||
if (file.isDirectory()) { | ||
compareFiles(inFolder, outFolder, folder + "/" + file.getName()); | ||
} else { | ||
System.out.println("File: " + folder + "/" + file.getName()); | ||
try { | ||
if (!fileCompare(inFolder + folder + "/" + file.getName(), | ||
outFolder + folder + "/" + file.getName())) { | ||
copyFile(inFolder + folder + "/" + file.getName(), outFolder + folder + "/" + file.getName()); | ||
System.out.println("File: " + folder + "/" + file.getName() + " updated"); | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.