Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!ucbvax!UM.CC.UMICH.EDU!Paul_Abrahams%Wayne-MTS From: Paul_Abrahams%Wayne-MTS@UM.CC.UMICH.EDU Newsgroups: comp.lang.icon Subject: MS-DOS file generator Message-ID: <251913@Wayne-MTS> Date: 24 Sep 90 22:33:42 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 52 In response to Richard's request, here is the MS-DOS file generator that I posted quite a while ago. I haven't even looked at it for over a year, but I don't suppose it has rusted. It would be nice if there were some repository for tidbits like this, but I guess the Icon project has enough else to do. Paul Abrahams abrahams%wayne-mts@um.cc.umich.edu ==================================================================== # get_filename(pfn) accepts a DOS filename possibly containing wildcards. # The filename can also include a drive letter and path. # If the filename ends in "\" or ":", "*.*" is appended. # The result sequence is a sequence of the filenames corresponding to pfn. procedure get_filename(pfn) local asciiz, fnr, prefix, k, name local ds, dx, result, fnloc, string_block #get Disk Transfer Address; filename locn is 30 beyond that result := Int86([16r21, 16r2f00] ||| list(7,0)) fnloc := 16 * result[8] + result[3]+ 30 # get the generalized filename fnr := reverse(pfn) k := upto("\\:", fnr) | *fnr + 1 prefix := reverse(fnr[k:0]) name := "" ~== reverse(fnr[1:k]) | "*.*" # Get the first file in the sequence asciiz := prefix || name || "\x00" Poke(string_block := GetSpace(*asciiz), asciiz) ds := string_block / 16 dx := string_block % 16 result := Int86([16r21, 16r4e00, 0, 0, dx, 0, 0, 0, ds]) case result[2] of { 0 : {} 18 : fail default : stop("i/o error ", result[2]) } suspend prefix || extract_name(fnloc) # Get the remaining files in the sequence while Int86([16r21, 16r4f00, 0, 0, 0, 0, 0, 0, 0])[2] = 0 do suspend prefix || extract_name(fnloc) end procedure extract_name(fnloc) local asciiz asciiz := Peek(fnloc, 13) return asciiz[1:upto("\x00", asciiz)] end