|
@@ -1,36 +1,66 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
- "cicv-data-closedloop/common/util"
|
|
|
"fmt"
|
|
|
- "log"
|
|
|
"os"
|
|
|
+ "path/filepath"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func replaceSymbolInDir(root string, oldSymbol, newSymbol string) error {
|
|
|
+ return filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if info.IsDir() {
|
|
|
+
|
|
|
+ newPath := strings.Replace(path, oldSymbol, newSymbol, -1)
|
|
|
+ if newPath != path {
|
|
|
+ fmt.Printf("Renaming %s to %s\n", path, newPath)
|
|
|
+ return os.Rename(path, newPath)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
func main() {
|
|
|
-
|
|
|
-
|
|
|
- dirPath := "D:\\code\\cicv-data-closedloop\\trigger\\pji\\diagnostics"
|
|
|
+ rootDir := "D:\\code\\cicv-data-closedloop\\trigger\\pji\\diagnostics"
|
|
|
+ oldSymbol := "#"
|
|
|
+ newSymbol := "_"
|
|
|
|
|
|
-
|
|
|
- files, err := os.ReadDir(dirPath)
|
|
|
+ err := replaceSymbolInDir(rootDir, oldSymbol, newSymbol)
|
|
|
if err != nil {
|
|
|
- log.Fatal(err)
|
|
|
+ fmt.Println("Error:", err)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- content := ""
|
|
|
- for _, file := range files {
|
|
|
-
|
|
|
- if file.IsDir() {
|
|
|
-
|
|
|
-
|
|
|
- fileName := strings.Replace(strings.Replace(file.Name(), " ", "", -1), "\n", "", -1)
|
|
|
- fmt.Println()
|
|
|
- content = content + "go build --buildmode=plugin -o ./so/pji/" + fileName + ".so ./trigger/pji/diagnostics/" + fileName + "/main/main.go" + "\n"
|
|
|
- }
|
|
|
- }
|
|
|
- util.WriteFile(content, "D:\\test.sh")
|
|
|
+ fmt.Println("Replacement completed successfully.")
|
|
|
}
|