(FILECREATED "19-Feb-87 17:52:48" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH204.;5 8196   

      changes to:  (VARS RHTPATCH204COMS)
		   (FNS NCLocalDevice.SaveInformationPastCheckpoint NCLocalDevice.TruncateNoteFile 
			NC.ProcessTruncationRequest)

      previous date: "19-Feb-87 10:58:01" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH204.;1)


(* Copyright (c) 1987 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT RHTPATCH204COMS)

(RPAQQ RHTPATCH204COMS ((* * Fix to bug #407: Truncate option when opening bad notefile once again 
			     allows saving data past checkpoint to a file.)
			  (* * Changes to NCDATABASE)
			  (FNS NC.ProcessTruncationRequest)
			  (* * Changes to NCLOCALDEVICE)
			  (FNS NCLocalDevice.TruncateNoteFile 
			       NCLocalDevice.SaveInformationPastCheckpoint)))
(* * Fix to bug #407: Truncate option when opening bad notefile once again allows saving data 
past checkpoint to a file.)

(* * Changes to NCDATABASE)

(DEFINEQ

(NC.ProcessTruncationRequest
  (LAMBDA (NoteFile NoteFilesHashArray Don'tCacheTypesAndTitlesFlg Don'tCreateFlg 
		    Convertw/oConfirmFlg Don'tCreateArrayFlg Don'tTruncateFlg Don'tCreateInterfaceFlg 
		    Don'tGetSpecialCardsFlg PromptWindow PublicOrPrivate 
		    Don'tCheckOperationsInProgressFlg MenuPosition QuietFlg ReadOnlyFlg)
                                                             (* rht: "19-Feb-87 10:57")

          (* * Do the actual truncation of a NoteFile that has stuf past the checkpoint pointer.)



          (* * fgh 5/25/86 First created.)



          (* * fgh 9/1/86 Updated args to match NC.OpenNoteFile.)



          (* * rht 2/19/87: Now passes PromptWindow arg to TruncationFn.)


    (LET (ReturnValue (TruncationFn (fetch (NoteFile TruncateNoteFileFn) of NoteFile)))

          (* * Do the truncation.)


         (if (type? NoteFile (CAR (ERSETQ (SETQ ReturnValue (APPLY* TruncationFn NoteFile 
										PromptWindow)))))
	     then 

          (* * Truncation successful, Open the note file.)


		    (NC.OpenNoteFile NoteFile NoteFilesHashArray Don'tCacheTypesAndTitlesFlg 
				       Don'tCreateFlg Convertw/oConfirmFlg Don'tCreateArrayFlg 
				       Don'tTruncateFlg Don'tCreateInterfaceFlg 
				       Don'tGetSpecialCardsFlg PromptWindow PublicOrPrivate T 
				       MenuPosition QuietFlg ReadOnlyFlg)
	   else 

          (* * Error during truncation fn. report and get out of here.)


		  (SELECTQ ReturnValue
			     (NoteFileTruncationAborted (QUOTE NoteFileTruncationAborted))
			     (PROGN (ERSETQ (NC.ReportError NIL (CONCAT 
						       "NoteFile truncation failed for NoteFile "
										(fetch
										  (NoteFile 
										     FullFileName)
										   of NoteFile)
										" because " 
										ReturnValue ".")))
				      (QUOTE NoteFileTruncationFailed)))))))
)
(* * Changes to NCLOCALDEVICE)

(DEFINEQ

(NCLocalDevice.TruncateNoteFile
  (LAMBDA (NoteFile PromptWindow)                            (* rht: "19-Feb-87 12:23")

          (* * Truncate a local device NoteFile back to the checkpoint pointer, offering the user the option of saving the 
	  changes in another file.)



          (* * fgh 5/25/86 First created on basis of old NC.CheckForNeededtruncation.)



          (* * rht 2/19/87: Now properly binds FullFileName.)


    (PROG ((FullFileName (fetch (NoteFile FullFileName) of NoteFile))
	     (NoteFileStream (fetch (NoteFile Stream) of NoteFile))
	     SaveStream ReturnValue)

          (* * Make sure PromptWindow is a window)


	    (OR (WINDOWP PromptWindow)
		  (SETQ PromptWindow))

          (* * Check to make NoteFile is not open. If it is, then error.)


	    (if (AND NoteFileStream (OPENP NoteFileStream))
		then (RETURN (QUOTE NoteFileAlreadyOpen)))

          (* * First ask the user if they want to save the info past the checkpoint into a file. If there's no PromptWindow, 
	  don't bother to ask.)


	    (if (AND PromptWindow (NC.AskYesOrNo 
						"Want to save info beyond checkpoint to a file? "
						       "--" "Yes" NIL PromptWindow NIL T))
		then (if (NOT (type? NoteFile (SETQ ReturnValue (
						 NCLocalDevice.SaveInformationPastCheckpoint 
											 NoteFile 
										     PromptWindow))))
			   then                            (* Save failed for some reason.
							     Notify the user and return.)
				  (NC.PrintMsg PromptWindow T 
						 "Attempt to save information failed because "
						 ReturnValue "." (CHARACTER 13))
				  (RETURN (QUOTE NoteFileTruncationFailed))))

          (* * Now truncate. Confirming with the user first if there's a prompt window.)


	    (if (OR (NOT PromptWindow)
			(NC.AskYesOrNo (CONCAT (CHARACTER 13)
						   "Are you sure you want to truncate " FullFileName 
						   "? ")
					 "--" "No" NIL PromptWindow NIL T))
		then 

          (* * Notify the user if appropriate.)


		       (AND PromptWindow (NC.PrintMsg PromptWindow T "Truncating file " 
							  FullFileName " ..."))

          (* * Do the truncation.)


		       (if (CAR (ERSETQ (SETFILEINFO FullFileName (QUOTE LENGTH)
							     (fetch (NoteFile CheckptPtr)
								of NoteFile))))
			   then 

          (* * truncation succeeded.)


				  (AND PromptWindow (NC.PrintMsg PromptWindow T "Done."
								     (CHARACTER 13)))
				  (RETURN NoteFile)
			 else 

          (* * truncation failed. Notify user.)


				(AND PromptWindow (NC.PrintMsg PromptWindow NIL 
								   "Couldn't truncate "
								   FullFileName "." (CHARACTER
								     13)
								   (CHARACTER 13)))
				(RETURN (QUOTE NoteFileTruncationFailed)))
	      else 

          (* * user aborted truncation.)


		     (RETURN (QUOTE NoteFileTruncationAborted))))))

(NCLocalDevice.SaveInformationPastCheckpoint
  (LAMBDA (NoteFile PromptWindow)                            (* rht: "19-Feb-87 17:39")

          (* * Save the information on NoteFile that is past the checkpoint pointer. Assume NoteFile is closed.)



          (* * fgh 5/25/86 First created.)



          (* * rht 2/19/87: Now properly binds FullFileName.)


    (PROG ((FullFileName (fetch (NoteFile FullFileName) of NoteFile))
	     NoteFileStream SaveStream SaveFile)

          (* * Open the NoteFile)


	    (if (NULL (CAR (ERSETQ (SETQ NoteFileStream (OPENSTREAM FullFileName
										(QUOTE INPUT)
										(QUOTE OLD)
										(QUOTE
										  ((TYPE BINARY)))))))
			  )
		then (RETURN (QUOTE CouldNotOpenNoteFile)))

          (* * Open the save file after asking the user to specify it.)


	    (SETQ SaveFile (NC.AskUser (CONCAT (CHARACTER 13)
						     "File to save info in: ")
					   NIL NIL NIL PromptWindow T))
	    (if (NULL (CAR (ERSETQ (SETQ SaveStream (AND SaveFile
								     (OPENSTREAM
								       SaveFile
								       (QUOTE OUTPUT)
								       NIL
								       (QUOTE ((TYPE BINARY)))))))))
		then (RETURN (QUOTE CouldNotOpenSaveFile)))

          (* * Copy the bytes from the NoteFile to the save file.)


	    (if (NULL (ERSETQ (PROGN (NC.PrintMsg PromptWindow T "Saving extra info to " 
							    SaveFile " ...")
					     (COPYBYTES NoteFileStream SaveStream
							  (fetch (NoteFile CheckptPtr)
							     of NoteFile))
					     (CLOSEF SaveStream)
					     (CLOSEF NoteFileStream)
					     (NC.PrintMsg PromptWindow NIL "Done." (CHARACTER
							      13)))))
		then (CLOSEF? SaveStream)
		       (DELFILE SaveStream)
		       (CLOSEF? NoteFileStream)
		       (RETURN (QUOTE CopyToSaveFileFailed))
	      else (RETURN NoteFile)))))
)
(PUTPROPS RHTPATCH204 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (965 2926 (NC.ProcessTruncationRequest 975 . 2924)) (2964 8114 (
NCLocalDevice.TruncateNoteFile 2974 . 6082) (NCLocalDevice.SaveInformationPastCheckpoint 6084 . 8112))
)))
STOP