(FILECREATED " 6-Jan-86 18:28:00" {QV}<NOTECARDS>1.3K>RHTPATCH019.;2 7450 changes to: (VARS RHTPATCH019COMS) previous date: " 6-Jan-86 17:44:45" {QV}<NOTECARDS>1.3K>RHTPATCH019.;1) (* Copyright (c) 1986 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT RHTPATCH019COMS) (RPAQQ RHTPATCH019COMS ((* * Fixed from NCDATABASE) (FNS NC.CheckForNeededConversion) (* * Fixed from NCCONVERTVERSION2TO3) (FNS NC.ConvertNoteFileVersion2To3))) (* * Fixed from NCDATABASE) (DEFINEQ (NC.CheckForNeededConversion (LAMBDA (NoteFile Convertw/oConfirmFlg) (* rht: " 6-Jan-86 16:50") (* * Check the version of NoteFile. If version 2, then convert if user confirms. If earlier than version 2, then bail out with informative message.) (LET ((Stream (fetch (NoteFile Stream) of NoteFile)) (Version (fetch (NoteFile Version) of NoteFile)) (FullFileName (fetch (NoteFile FullFileName) of NoteFile)) NewFileName) (COND ((EQ Version 3) NoteFile) ((GEQ Version 4) (NC.ReportError "NC.CheckForNeededConversion" (CONCAT "Version number of notefile: " FullFileName " is greater than 3.")) NIL) ((LEQ Version 1) (NC.PrintMsg NIL T "Notefile " FullFileName " is too old (version " Version "). It must first be converted to version 2 by opening in NoteCards release 1.2i. Then we convert to version 3." (CHARACTER 13)) NIL) ((AND Convertw/oConfirmFlg (NOT (NC.YesP (NC.AskUser (CONCAT "Notefile: " FullFileName " is version 2." (CHARACTER 13) "Want to convert to version 3? ") NIL (QUOTE Yes) T NIL T NIL T)))) NIL) ((SETQ NewFileName (NC.AutoloadApply* (FUNCTION NC.ConvertNoteFileVersion2To3) Stream)) (* * Things are okay. File was version 2 and has been converted to version 3) (if (SETQ Stream (CAR (ERSETQ (OPENSTREAM NewFileName Access (QUOTE OLD) (QUOTE ((TYPE BINARY))))))) then (* Redo the work at the top of NC.OpenDatabaseFile.) (replace (NoteFile Stream) of NoteFile with Stream) (replace (NoteFile FullFileName) of NoteFile with (FULLNAME Stream)) (NC.SetMonitor NoteFile (CREATE.MONITORLOCK (MKATOM (CONCAT NewFileName ":LOCK")))) (NC.GetNoteFileHeader NoteFile) NoteFile else (NC.ReportError "NC.CheckForNeededConversion" (CONCAT "Couldn't open " NewFileName " after running NC.ConvertNoteFileVersion2To3." (CHARACTER 13))) NIL)) (T NIL))))) ) (* * Fixed from NCCONVERTVERSION2TO3) (DEFINEQ (NC.ConvertNoteFileVersion2To3 (LAMBDA (StreamOrFileName) (* rht: " 6-Jan-86 18:22") (* * Convert this notefile to version 3 outputting the version 3 notefile to new version with same filename.) (* * fgh 12/17/85 fixed call to CreateDatabaseFile to lop the version off of the file name.) (* * rht 12/18/85: Now clears Version2HashArray in case uncollectable garbage is left around.) (LET ((OperationMsg "Converting file to version 3.") CardTotal FileName FromStream FromNoteFile ToNoteFile Version2HashArray Version NextIndexNum IndexSizeInEntries NextLinkNum CheckptPtr ToFileName) (if (STREAMP StreamOrFileName) then (SETQ FromStream StreamOrFileName) (SETQ FileName (FULLNAME StreamOrFileName)) else (SETQ FileName StreamOrFileName) (SETQ FromStream (OPENSTREAM FileName (QUOTE BOTH)))) (SETFILEPTR FromStream 7) (if (EQ (SETQ Version (NC.ReadPtr FromStream 1)) 2) then (* FromStream is indeed version 2.0) (* Get all the header info off the 1.2 stream.) (SETFILEPTR FromStream 0) (SETQ NextIndexNum (NC.ReadPtr FromStream 2)) (SETQ CardTotal (SUB1 NextIndexNum)) (SETQ IndexSizeInEntries (NC.ReadPtr FromStream 2)) (SETQ NextLinkNum (NC.ReadPtr FromStream 3)) (* Skip version number.) (NC.ReadPtr FromStream 1) (SETQ CheckptPtr (NC.ReadPtr FromStream 3)) (* * Create a dummy notefile object for the 1.2 source notefile.) (SETQ FromNoteFile (create NoteFile UID ←(NC.MakeUID) Stream ← FromStream FullFileName ←(FULLNAME FileName) NextIndexNum ← NextIndexNum Version ← Version NextLinkNum ← NextLinkNum CheckptPtr ← CheckptPtr)) (SETQ ToNoteFile (NC.CreateDatabaseFile (PACKFILENAME (QUOTE VERSION) NIL (QUOTE BODY) FileName) IndexSizeInEntries OperationMsg T)) (SETQ ToFileName (fetch (NoteFile FullFileName) of ToNoteFile)) (if (AND (type? NoteFile ToNoteFile) (NC.OpenDatabaseFile ToNoteFile NIL T T NIL NIL NIL NIL T)) then (* * Fill in NewNoteFile's hash array with new UIDs. Return a hash array mapping version 2 style ID atoms to version 3 style Cards.) (NC.PrintMsg NIL T "Reading index of version 2 notefile ...") (SETQ Version2HashArray (NC.BuildVersion2HashArray FromNoteFile ToNoteFile CardTotal)) (* * For each card in the old notefile, fill in a version 3 card object for it and put the filled in card down to NewNoteFile.) (NC.PrintMsg NIL T OperationMsg (CHARACTER 13) "Processing card ID 1 out of " CardTotal) (for IDNum from 1 to CardTotal eachtime (BLOCK) do (if (ZEROP (REMAINDER IDNum 10)) then (NC.PrintMsg NIL T OperationMsg (CHARACTER 13) "Processing card ID " IDNum " out of " CardTotal)) (NC.GetAndPutVersion2Card FromStream (NC.IDFromNumber IDNum) Version2HashArray FromNoteFile ToNoteFile)) (* Clear hash array to be sure uncollectable garbage isn't left around.) (CLRHASH Version2HashArray) (NC.CheckpointDatabase ToNoteFile T) (NC.ForceDatabaseClose ToNoteFile) (CLOSEF FromStream) (* Rebuild To and From links.) (NC.ScavengeDatabaseFile (fetch (NoteFile FullFileName) of ToNoteFile)) (NC.PrintMsg NIL T "Done.") ToFileName) else (NC.ReportError "NC.ConvertNoteFileVersion2To3" (CONCAT "Filename " FileName " is version " Version ". Can only convert version 2 notefiles.")) NIL)))) ) (PUTPROPS RHTPATCH019 COPYRIGHT ("Xerox Corporation" 1986)) (DECLARE: DONTCOPY (FILEMAP (NIL (523 2919 (NC.CheckForNeededConversion 533 . 2917)) (2964 7368 ( NC.ConvertNoteFileVersion2To3 2974 . 7366))))) STOP