From f8a2b43b2258029b6d931c1848677939e14e2e38 Mon Sep 17 00:00:00 2001 From: Rob van Son Date: Mon, 29 Sep 2014 15:52:41 +0200 Subject: [PATCH] Handle broken wordlists and audio files --- Config.praat | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Config.praat b/Config.praat index 6f95e54..022102d 100644 --- a/Config.praat +++ b/Config.praat @@ -903,7 +903,7 @@ procedure removeWordlist .deletedWordlistName$ deleteFile("'.targetDir$'/'.file$'") endfor filedelete '.targetDir$' - if windows + if windows and index(.deletedWordlistName$, "[^a-zA-Z0-9_ \.\-~]") <= 0 system rmdir "'.targetDir$'" /s /q endif # Remove deleted word list @@ -971,7 +971,7 @@ procedure readWordlist .sourceDir$ .file$ # Create wordlist directory createDirectory(.wordlistDirectory$) .wasWordList = 1 - if index_regex(.wordlistDirectory$, "[^a-zA-Z0-9_\.\- /~]") <= 0 + if index_regex(.wordlistDirectory$, "[^a-zA-Z0-9_\.\- /~]") <= 0 and index_regex(.dirname$, "[^a-zA-Z0-9_\.\- ]") <= 0 if macintosh or unix system bash -rc -- 'cp "'.sourceDir$'/'.file$'" "'.wordlistDirectory$'/"' system cd ''.wordlistDirectory$'';bash -rc -- 'unzip "'.file$'"' @@ -1006,7 +1006,7 @@ procedure readWordlist .sourceDir$ .file$ ### REALLY DANGEROUS STUFF, SHOULD BE HANDLED BETTER if .wasWordList = 0 # Remove newly created directory - if index_regex(.wordlistDirectory$, "[^a-zA-Z0-9_\.\- /~]") <= 0 + if index_regex(.wordlistDirectory$, "[^a-zA-Z0-9_\.\- /~]") <= 0 and index_regex(.dirname$, "[^a-zA-Z0-9_\.\- ]") <= 0 if macintosh or unix system bash -rc -- 'rm -r "'.wordlistDirectory$'/"' elsif windows @@ -1041,14 +1041,16 @@ procedure readWordlist .sourceDir$ .file$ endif elsif fileReadable("'.sourceDir$'/'.file$'/wordlist.Table") or fileReadable("'.sourceDir$'/'.file$'/wordlist.txt") or fileReadable("'.sourceDir$'/'.file$'/LICENSE.txt") # Copy wordlist directory - .wasWordList = 1 - if macintosh or unix - system bash -rc -- 'cp -r "'.sourceDir$'/'.file$'" "'.wordlistDirectory$'"' - elsif windows - createDirectory(.wordlistDirectory$) - .winWordListDirectory$ = replace_regex$(.wordlistDirectory$, "/", "\\", 0) - .winSourceDirectory$ = replace_regex$("'.sourceDir$'\'.file$'", "/", "\\", 0) - system xcopy "'.winSourceDirectory$'" "'.winWordListDirectory$'" /s /e /q + if index_regex(.file$, "[^a-zA-Z0-9_\.\- ]") <= 0 + .wasWordList = 1 + if macintosh or unix + system bash -rc -- 'cp -r "'.sourceDir$'/'.file$'" "'.wordlistDirectory$'"' + elsif windows + createDirectory(.wordlistDirectory$) + .winWordListDirectory$ = replace_regex$(.wordlistDirectory$, "/", "\\", 0) + .winSourceDirectory$ = replace_regex$("'.sourceDir$'\'.file$'", "/", "\\", 0) + system xcopy "'.winSourceDirectory$'" "'.winWordListDirectory$'" /s /e /q + endif endif endif -- 2.11.4.GIT