This file is indexed.

/usr/share/axiom-20170501/src/algebra/KAFILE.spad is in axiom-source 20170501-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
)abbrev domain KAFILE KeyedAccessFile
++ Author: Stephen M. Watt
++ Date Created: 1985
++ Date Last Updated: June 4, 1991
++ Description:
++ This domain allows a random access file to be viewed both as a table
++ and as a file object. The KeyedAccessFile format is a directory 
++ containing a single file called ``index.kaf''. This file is a random
++ access file. The first thing in the file is an integer which is the
++ byte offset of an association list (the dictionary) at the end of
++ the file. The association list is of the form
++ ((key . byteoffset) (key . byteoffset)...)
++ where the byte offset is the number of bytes from the beginning of
++ the file. This offset contains an s-expression for the value of the key.
 
KeyedAccessFile(Entry) : SIG == CODE where
  Entry : SetCategory
 
  Name  ==> FileName
  Key   ==> String

  SIG ==> Join(FileCategory(Name, Record(key: Key, entry: Entry)),
               TableAggregate(Key, Entry)) with

    finiteAggregate

    pack_! : % -> %
      ++ pack!(f) reorganizes the file f on disk to recover 
      ++ unused space.
 
  CODE ==> add
 
    CLASS     ==> 131   -- an arbitrary no. greater than 127
    FileState ==> SExpression
    IOMode    ==> String
  
    Cons:= Record(car: SExpression, cdr: SExpression)
    Rep := Record(fileName:    Name,     _
                  fileState:   FileState,   _
                  fileIOmode:  IOMode)
 
    defstream(fn: Name, mode: IOMode): FileState ==
        kafstring:=concat(fn::String,"/index.kaf")::FileName
        mode = "input"  =>
          not readable? kafstring => error ["File is not readable", fn]
          RDEFINSTREAM(fn)$Lisp
        mode = "output" =>
          not writable? fn => error ["File is not writable", fn]
          RDEFOUTSTREAM(fn)$Lisp
        error ["IO mode must be input or output", mode]
 
        ---- From Set ----

    f1 = f2 ==
        f1.fileName = f2.fileName

    coerce(f: %): OutputForm ==
        f.fileName::OutputForm
 
        ---- From FileCategory ----

    open fname ==
        open(fname, "either")

    open(fname, mode) ==
        mode = "either" =>
            exists? fname =>
                open(fname, "input")
            writable? fname =>
                reopen_!(open(fname, "output"), "input")
            error "File does not exist and cannot be created"
        [fname, defstream(fname, mode), mode]

    reopen_!(f, mode) ==
        close_! f
        if mode ^= "closed" then
            f.fileState := defstream(f.fileName, mode)
            f.fileIOmode  := mode
        f

    close_! f  ==
        if f.fileIOmode ^= "closed" then
            RSHUT(f.fileState)$Lisp
            f.fileIOmode  := "closed"
        f

    read_! f ==
        f.fileIOmode ^= "input" => error ["File not in read state",f]
        ks: List Symbol := RKEYIDS(f.fileName)$Lisp
        null ks => error ["Attempt to read empty file", f]
        ix := random()$Integer rem #ks
        k: String := PNAME(ks.ix)$Lisp
        [k, SPADRREAD(k, f.fileState)$Lisp]

    write_!(f, pr) ==
        f.fileIOmode ^= "output" => error ["File not in write state",f]
        SPADRWRITE(pr.key, pr.entry, f.fileState)$Lisp
        pr

    name f ==
        f.fileName

    iomode f ==
        f.fileIOmode
 
        ---- From TableAggregate ----

    empty() ==
        fn := new("", "kaf", "sdata")$Name
        open fn

    keys f ==
        close_! f
        l: List SExpression := RKEYIDS(f.fileName)$Lisp
        [PNAME(n)$Lisp for n in l]

    # f ==
        # keys f

    elt(f,k) ==
        reopen_!(f, "input")
        SPADRREAD(k, f.fileState)$Lisp

    setelt(f,k,e) ==
        -- Leaves f in a safe, closed state.  For speed use "write".
        reopen_!(f, "output")
        UNWIND_-PROTECT(write_!(f, [k,e]), close_! f)$Lisp
        close_! f
        e

    search(k,f) ==
        not member?(k, keys f) => "failed"   -- can't trap RREAD error
        reopen_!(f, "input")
        (SPADRREAD(k, f.fileState)$Lisp)@Entry

    remove_!(k:String,f:%)  ==
        result := search(k,f)
        result case "failed" => result
        close_! f
        RDROPITEMS(NAMESTRING(f.fileName)$Lisp, LIST(k)$Lisp)$Lisp
        result

    pack_! f ==
        close_! f
        RPACKFILE(f.fileName)$Lisp
        f