home *** CD-ROM | disk | FTP | other *** search
- -- 2001.01.27
- -- Clive Green <clivegreen@atlas.co.uk>
-
- ------------------------------------------------------------------------------------------------------
-
- -- taps into features of the Buddy API Xtra:
-
- ------------------------------------------------------------------------------------------------------
-
- -- declare properties:
- property main -- main code directory object
- property dataManager -- data storage facility
- property buddyManager -- buddyAPI manager
-
- property cdTitle -- the (Macintosh) CD-ROM desktop title
- property defaultCDtitle -- default value for cdTitle
- property rootPrefix -- runtime CD-ROM path prefix string (ie: "F:\" or "LineOne:")
-
- ------------------------------------------------------------------------------------------------------
-
- on new me,L
-
- -- (1) extract and check arguments:
-
- -- check for a parameter list:
- if ilk(L) <> #propList then return [#error:#noParamListSupplied, #msg:"CDROMservice:new"]
-
- -- a reference to the parent codebase is REQUIRED:
- main = L[#main]
- if (ilk(main) <> #instance) then return [#error:#noMainObjectSupplied, #msg:"CDROMservice:new"]
-
- --------------------
-
- -- (2) obtain locally required features and services:
-
- -- get the data manager:
- dm = main.getDataManager()
- if (ilk(dm) <> #instance) then return dm
-
- dataManager = dm
-
- -- use the buddyAPIxtra controller:
- xm = main.getXtrasManager()
- if (ilk(xm) <> #instance) then return xm
-
- bm = xm.getBuddyAPIxtra()
- if (ilk(bm) <> #instance) then return bm
-
- buddyManager = bm
-
- --------------------
-
- -- (3) store literals:
- defaultCDtitle = "LineOne"
- cdTitle = defaultCDtitle
-
- --------------------
-
- -- (4) what is the disc name for this title? (used for Mac versions of the programme):
- d = dataManager.getData([#set:#settings, #item:#titling])
- t = d[#cdTitle]
-
- -- override default cd title with a custom one if this is found
- if stringP(t) then cdTitle = t
-
- --------------------
-
- -- pass back validated manager object to the caller:
- return me
-
- ----------------------------------------------------------------------------------------------------
-
- on launchCDfile me,L
-
- -- we need a parameter listing:
- if ilk(L) <> #propList then return ¬
- [#error:#noParamListSupplied, #msg:"CDROMservice :launchCDfile"]
-
- -- extract the filePath supplied:
- f = L[#filePath]
-
- if not stringP(f) then return ¬
- [#error:#badFilePathSupplied, #msg:"CDROMservice :launchCDfile"]
-
- -- in what manner should the file be opened?
- s = L[#state]
- if not stringP(s) then s = "Normal"
-
- --------------------
-
- -- we also need a correctly identified CD-ROM to continue!
- if voidP(rootPrefix) then return ¬
- [#error:#CDmissing, #msg:"CDROMservice:launchCDfile"]
-
- --------------------
-
- -- attempt to launch from the correct CD
- L[#filePath] = rootPrefix & f
- return buddyManager.launchFile(L)
-
- ----------------------------------------------------------------------------------------------------
-
- on matchingCDfound me
-
- -- this is a development cheat:
- if the SHIFTDOWN then
-
- -- use the local path instead of a mounted CD:
- rootPrefix = dataManager.getRootPath()
- return 1
-
- end if
-
- --------------------
-
- -- we first need to find a mounted CD-ROM with a specific director file on it.
- -- this file is addressed as a miaw, and asked to return its version information
- -- if the version info matches with what we know locally, then we have found our CD
-
- -- (1) compile a linear list of CD-ROM drive letters or names:
- CDROMdrives = []
-
- -- CD-ROM location varies according to platform:
- um = main.getUtilityMethods()
- p = um.thePlatform()
-
- if (p = #PC) then
-
- repeat with i = charToNum("A") to charToNum("Z")
-
- -- get ith drive letter:
- d = numToChar(i)
-
- -- we want CD-ROM drives only:
- if buddyManager.driveIsCDROM(d) then add CDROMdrives,(d & ":\")
-
- end repeat
-
- else
-
- -- on the Mac, we can specify the CD title exactly:
- CDROMdrives = [cdTitle & ":"]
-
- end if
-
- --------------------
-
- -- (2) obtain the partial filePath to the 'version' miaw:
- dL = dataManager.getData([#set:#filePaths, #item:#version])
- fp = dL[#filePath]
-
- -- parse the path for the current platform:
- um = main.getUtilityMethods()
- fp = um.parseFilePath(fp)
-
- --------------------
-
- -- (3) now we need to check all currently mounted CD-ROMs for the existence of our
- -- version file fp:
- repeat with i in CDROMdrives
-
- -- compile a full filePath to our prospective version file:
- f = i & fp
-
- -- does this file exist?
- f = buddyManager.fileExists(f)
- if not stringP(f) then next repeat
-
- -- we found our file! now test whether the version it specifies is correct:
- if not me.matchedVersionString(f) then next repeat
-
- -- success! now we know our CD-ROM root:
- rootPrefix = i
-
- -- flag success to the caller
- return 1
-
- end repeat
-
- -- if we got here, then no CORRECT version movie on a mounted CD was found:
- return 0
-
- ----------------------------------------------------------------------------------------------------
-
- on matchedVersionString me,f
-
- -- ask the director movie file f for its version string:
- w = window(f)
- tell w to v = getVersionDataString()
-
- -- dispose:
- forget w
-
- --------------------
-
- -- tell the caller whether we have a match:
- return (field("versionDataString") = v)
-
- ----------------------------------------------------------------------------------------------------