@@ -174,18 +174,38 @@ function FileSystemObject() {
174174return true ;
175175 } ;
176176 this . fileexists = ( path ) => {
177- const value = ! argv [ "no-file-exists" ] ;
177+ var value = ! argv [ "no-file-exists" ] ;
178178if ( value ) {
179179 lib . info ( `Returning true for FileSystemObject.FileExists(${ path } ); use --no-file-exists if nothing happens` ) ;
180180}
181+ if ( typeof ( this . _fileCheckCount ) == "undefined" ) this . _fileCheckCount = 0 ;
182+ this . _fileCheckCount ++ ;
183+ if ( argv [ "limit-file-checks" ] && ( this . _fileCheckCount > 10 ) ) {
184+ // Flip whether the file exists or not to see if that
185+ // breaks a loop.
186+ value = ! value ;
187+ // Might break emulation based on WScript.quit(). Stop
188+ // ignoring WScript.quit().
189+ lib . doWscriptQuit ( true ) ;
190+ }
181191 lib . logIOC ( "FileExists" , path , "The script checked to see if a file exists." ) ;
182192return value ;
183193 } ;
184194 this . folderexists = ( path ) => {
185- const value = ! argv [ "no-folder-exists" ] ;
195+ var value = ! argv [ "no-folder-exists" ] ;
186196if ( value ) {
187197 lib . info ( `Returning true for FileSystemObject.FolderExists(${ path } ); use --no-folder-exists if nothing happens` ) ;
188198}
199+ if ( typeof ( this . _fileCheckCount ) == "undefined" ) this . _fileCheckCount = 0 ;
200+ this . _fileCheckCount ++ ;
201+ if ( argv [ "limit-file-checks" ] && ( this . _fileCheckCount > 500 ) ) {
202+ // Flip whether the file exists or not to see if that
203+ // breaks a loop.
204+ value = ! value ;
205+ // Might break emulation based on WScript.quit(). Stop
206+ // ignoring WScript.quit().
207+ lib . doWscriptQuit ( true ) ;
208+ }
189209 lib . logIOC ( "FolderExists" , path , "The script checked to see if a folder exists." ) ;
190210return value ;
191211 } ;
0 commit comments