Index: TECH/File/FileWriter.cls.xml =================================================================== diff -u -r2880 -r2927 --- TECH/File/FileWriter.cls.xml (.../FileWriter.cls.xml) (revision 2880) +++ TECH/File/FileWriter.cls.xml (.../FileWriter.cls.xml) (revision 2927) @@ -39,6 +39,7 @@ /// Nagaan of reeds naar bestand wordt geschreven door ander process Set ..LockHelper = ##class(TECH.Lock).%New(..GeefLockKey()) + w !,"LockHelper : "_..GeefLockKey(),! If ('..LockHelper.HeeftLock()) { Do ..LockHelper.Lock(##class(TECH.enu.LockType).Exclusive()) }Else{ @@ -81,7 +82,7 @@ } /// Close stream - Set Status = ..FileCharacterStream.Close() + Set Status = ..FileCharacterStream.%Close() If ($$$ISERR(Status)){ Set Exception = ##class(TECH.Exceptions.FileException).%New("Bestand kon niet worden gesloten '"_Filename_"' (Doelbestand :"_..Bestand_")",Status) Do ##class(TECH.ExceptionHandler).Throw(Exception) @@ -90,20 +91,27 @@ /// Bestand kopieren indien WriteImmediate niet aan stond. /// Handig voor snelheid bij wegschrijven naar netwerklocatie If ('..WriteImmediate){ - Set Gelukt = ##class(%File).CopyFile(Filename,..Bestand) - If (Gelukt){ - Set DeleteGelukt = ##class(TECH.File).Delete(Filename) - If (DeleteGelukt){ - Set Exception = ##class(TECH.Exceptions.FileException).%New("Bestand kon niet worden verwijderd '"_Filename_"'",0) - Do ##class(TECH.ExceptionHandler).Throw(Exception) - } - }Else{ - Set DeleteGelukt = ##class(TECH.File).Delete(Filename) - Set Exception = ##class(TECH.Exceptions.FileException).%New("Bestand kon niet worden verplaatst. '"_Filename_"' naar '"_..Bestand_"'. "_Filename_" is verwijderd ? "_DeleteGelukt_".",0) - Do ##class(TECH.ExceptionHandler).Throw(Exception) + Set Gelukt = ##class(%File).CopyFile(Filename,..Bestand) + If (##class(TECH.File).Exists(Filename)){ + If (Gelukt){ + Set DeleteGelukt = ##class(TECH.File).Delete(Filename) + If (DeleteGelukt){ + Set Exception = ##class(TECH.Exceptions.FileException).%New("Bestand kon niet worden verwijderd '"_Filename_"'",0) + Do ##class(TECH.ExceptionHandler).Throw(Exception) + } + }Else{ + Set DeleteGelukt = ##class(TECH.File).Delete(Filename) + Set Exception = ##class(TECH.Exceptions.FileException).%New("Bestand kon niet worden verplaatst. '"_Filename_"' naar '"_..Bestand_"'. "_Filename_" is verwijderd ? "_DeleteGelukt_".",0) + Do ##class(TECH.ExceptionHandler).Throw(Exception) + } } } Set ..FileCharacterStream = "" + + Do ..LockHelper.UnLock(##class(TECH.enu.LockType).Exclusive()) + + Set $ZTRAP = "" + Quit $$$OK Catch Set $ZTRAP = "" Do ..LockHelper.UnLock(##class(TECH.enu.LockType).Exclusive())