(FILECREATED " 7-Jul-87 18:13:58" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH283.;1 4547   

      changes to:  (VARS RHTPATCH283COMS))


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

(PRETTYCOMPRINT RHTPATCH283COMS)

(RPAQQ RHTPATCH283COMS ((* * Fixed a bug introduced by previous patch that was preventing 
			     conversion of 1.2 files to 1.3.)
			  (* * Change to NCLOCALDEVICE)
			  (FNS NCLocalDevice.OpenNoteFile)))
(* * Fixed a bug introduced by previous patch that was preventing conversion of 1.2 files to 
1.3.)

(* * Change to NCLOCALDEVICE)

(DEFINEQ

(NCLocalDevice.OpenNoteFile
  (LAMBDA (NoteFile PromptWindow Don'tCheckForTruncationFlg)
                                                             (* rht: " 7-Jul-87 18:08")

          (* * OpenNoteFileFn for the local, single user device.)



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



          (* * fgh 9/1/86 Reimplemented ReadOnly notefile.)



          (* * rht 10/31/86: Added Don'tCheckForTruncationFlg arg.)



          (* * rht 6/8/87: Switched order of checks of version num and plausibility. It was also ignoring the error value 
	  returned by NCLocalDevice.CheckForPlausibleNoteFileHeader.)



          (* * rht 7/7/87: Undid first half of previous change. I.e. order of checks of version num and plausibility is back 
	  to the way it used to be.)


    (OR (CAR (ERSETQ (PROG ((FullName (INFILEP (fetch (NoteFile FullFileName)
							    of NoteFile)))
				    EofPtr CriticalUIDs Stream ReturnVal)

          (* * First check for possible errors.)


			           (if (NULL FullName)
				       then 

          (* * Error: NoteFileNotFound, Return)


					      (RETURN (QUOTE NoteFileNotFound))
				     elseif (OPENP FullName)
				       then 

          (* * Error: NoteFile already open, Return)


					      (RETURN (QUOTE NoteFileAlreadyOpen))
				     elseif (NULL (ERSETQ (SETQ Stream
								  (OPENSTREAM
								    FullName
								    (if (fetch (NoteFile 
										      ReadOnlyFlg)
									     of NoteFile)
									then (QUOTE INPUT)
								      else (QUOTE BOTH))
								    (QUOTE OLD)
								    (QUOTE ((TYPE BINARY)))))))
				       then 

          (* * Error: File won't open)


					      (RETURN (QUOTE NoteFileOpenFailed)))

          (* * All is okay for now, create fill in the NoteFile object a bit.)


			           (replace (NoteFile Stream) of NoteFile with Stream)
			           (replace (NoteFile FullFileName) of NoteFile with FullName)
			           (NC.SetMonitor NoteFile (CREATE.MONITORLOCK FullName))

          (* * Make sure stream is not closed by CLOSEALLs)


			           (WHENCLOSE Stream (QUOTE CLOSEALL)
						(QUOTE NO))

          (* * Get the header and check for correct version, correct checkpoint, & plausibility.)


			           (NCLocalDevice.GetNoteFileHeader NoteFile)
			           (SETQ EofPtr (GETEOFPTR (fetch (NoteFile Stream)
								  of NoteFile)))
			           (COND
				     ((NOT (NCLocalDevice.NoteFileVersionOkayP NoteFile))
				       (RETURN (NCLocalDevice.OpenFailed NoteFile (QUOTE 
									  NoteFileNeedsConversion))))
				     ((NOT (type? NoteFile (SETQ ReturnVal (
						    NCLocalDevice.CheckForPlausibleNoteFileHeader
							  NoteFile EofPtr))))
				       (RETURN (NCLocalDevice.OpenFailed NoteFile ReturnVal)))
				     ((AND (NULL Don'tCheckForTruncationFlg)
					     (NCLocalDevice.NoteFileNeedsTruncationP NoteFile 
										       EofPtr))
				       (RETURN (NCLocalDevice.OpenFailed NoteFile (QUOTE 
									  NoteFileNeedsTruncation)))))

          (* * Go get the first six card UIDs on the file.)


			           (SETQ CriticalUIDs (NCLocalDevice.GetSpecialCardUIDs NoteFile))
			           (replace (NoteFileCriticalUIDs NoteFile) of CriticalUIDs
				      with (fetch (NoteFile UID) of NoteFile))

          (* * Return with list of special uids and NF-UID.)


			           (RETURN CriticalUIDs))))
	  (PROGN 

          (* * Open must have failed. Return a message to that effect.)


		   (NCLocalDevice.OpenFailed NoteFile)))))
)
(PUTPROPS RHTPATCH283 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (588 4465 (NCLocalDevice.OpenNoteFile 598 . 4463)))))
STOP