(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP")
(FILECREATED "20-Oct-88 14:37:17" {QV}<NOTECARDS>1.3LNEXT>RARPATCH046.;2 5988   

      changes to%:  (VARS RARPATCH046COMS)
                    (FNS NCLocalDevice.CreateNoteFile)

      previous date%: "20-Oct-88 14:27:24" {QV}<NOTECARDS>1.3LNEXT>RARPATCH046.;1)


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

(PRETTYCOMPRINT RARPATCH046COMS)

(RPAQQ RARPATCH046COMS (
                        (* ;; 
           "Fixes Lyric bug caused by passing explicit version number when creating files on {CORE}.")

                        
                        (* ;; "Change in NCLOCALDEVICE.")

                        (FNS NCLocalDevice.CreateNoteFile)))



(* ;; "Fixes Lyric bug caused by passing explicit version number when creating files on {CORE}.")




(* ;; "Change in NCLOCALDEVICE.")

(DEFINEQ

(NCLocalDevice.CreateNoteFile
  [LAMBDA (NoteFile SizeInCards InterestedWindow OperationMsg QuietFlg)
                                                             (* ; "Edited 20-Oct-88 14:25 by RAR")

         (* * Create an empty NoteFile on the local device.)

         (* * fgh |9/1/86| First created from NC.CloseDatabaseFile.)

    (* ;; "RAR. 10/20/88 Remove the version number if creating a notefile on ")

    (DECLARE (GLOBALVARS NCLocalDevice.CurrentVersionNumber NC.DefaultIndexSizeInEntries))
    (LET ((HashArraySize (OR (FIXP SizeInCards)
                             NC.DefaultIndexSizeInEntries))
          (FileName (fetch (NoteFile FullFileName) of NoteFile))
          Stream)
         (OR [CAR (ERSETQ (PROG NIL

         (* * Open the file.)

                                (if (EQ (FILENAMEFIELD FileName 'HOST)
                                        'CORE)
                                    then (SETQ FileName (PACKFILENAME 'VERSION NIL 'BODY FileName)))
                                [COND
                                   ([NULL (SETQ Stream (CAR (ERSETQ (OPENSTREAM FileName 'BOTH
                                                                           'NEW
                                                                           '((TYPE BINARY]
                                    (RETURN 'FileWon'tOpen]

         (* * Fix up the NoteFile object with the necessary information about the file 
         about to be created.)

                                (replace (NoteFile Stream) of NoteFile with Stream)
                                (replace (NoteFile FullFileName) of NoteFile with (FULLNAME Stream))
                                (replace (NoteFile HashArraySize) of NoteFile with HashArraySize)
                                (replace (NoteFile Version) of NoteFile with 
                                                           NCLocalDevice.CurrentNoteFileVersionNumber
                                       )
                                (replace (NoteFile CheckptPtr) of NoteFile with (
                                                                 NCLocalDevice.TotalNoteFileIndexSize
                                                                                 HashArraySize))
                                [replace (NoteFile NextIndexNum) of NoteFile
                                   with (CONSTANT (ADD1 (fetch (NoteFileVersion NumberOfReservedCards
                                                                      ) of (
                                                                         NCLocalDevice.CurrentVersion
                                                                            ]

         (* * Write the header down to the file.)

                                (NCLocalDevice.PutNoteFileHeader NoteFile)

         (* * Write an empty index onto the file.)

                                [for CTR from 1 to HashArraySize eachtime (BLOCK)
                                   do [OR QuietFlg (AND (EQ 1 (IMOD CTR 500))
                                                        (NC.PrintMsg InterestedWindow T
                                                               (OR OperationMsg "")
                                                               "Creating NoteFile."
                                                               (CHARACTER 13)
                                                               "Processing item " CTR " out of " 
                                                               HashArraySize "." (CHARACTER 13]
                                      (NC.WriteStatus Stream 'FREE)
                                      (SETFILEPTR Stream (PLUS (GETFILEPTR Stream)
                                                               (CONSTANT (SUB1 (fetch (
                                                                                      NoteFileVersion
                                                                                       
                                                                                   NoteFileIndexWidth
                                                                                       )
                                                                                  of (
                                                                         NCLocalDevice.CurrentVersion
                                                                                      ]

         (* Move NextIndexNum back to the beginning so that special cards will have the 
         correct index nums.)

                                (RETURN NoteFile]
             (PROGN 

         (* * Hmm. Create failed for some reason.)

                    (CLOSEF Stream (DELFILE (FULLNAME Stream)))
                    'CreateFailed])
)
(PUTPROPS RARPATCH046 COPYRIGHT ("Xerox Corporation" 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (910 5905 (NCLocalDevice.CreateNoteFile 920 . 5903)))))
STOP