Problems with snow leopard
David Bovill
david at architex.tv
Mon Sep 14 04:20:33 EDT 2009
In another context my mother once told me go for compatibility over beauty
any time :)
2009/9/14 Jerry J <jhj at jhj.com>
> On Sep 13, 2009, at 7:56 PM, Richard Gaskin wrote:
>
> With every step Apple takes to eliminate differences between OSes, the
>> less forked code we need to write. As they decrease their unique value, they
>> increase ours. :)
>>
>
> Very quotable! Thanks, Richard.
>
Seems like the detailed files no longer returns filetype info in Snow
Leopard. Wandering how to get this - would it not be good if the engine
moved over to using spotlight for OSX? I guess according to the above
principle not :)
I've an untested sketch of a handler - I'll post here that tries to get
basic file types - that is map a file path to one of the data types rev can
display - image, player, text, text. Text could be broken down to htmltext,
rtftext, text and unicode. Does anyone have any handlers for this -
suggestions regarding cross platform techniques?
function file_GetType filePath
> switch the platform
> case "MacOS"
> --get file_DetailedInfo (filePath)
> -- put item 11 of it into fType
> put spotlight_Kind (filePath) into fType
> return word -1 of fType
> case "Win32"
> put offset(".",filePath) into tChar
> if tChar <> 0 then
> put char tChar to length(filePath) of filePath into text
> put
> queryregistry("HKEY_CLASSES_ROOT\"&(queryregistry("HKEY_CLASSES_ROOT\"&tExt&
> "\")) & "\") into tType
> else
> put "" into tType
> put "" into text
> end if
> if tType = "" then
> if text <> "" then
> delete char 1 of text -- remove "."
> put toupper(tExt) && "File" into tType
> else
> put "File" into tType
> end if
> end if
> return filePath & numtochar(9) & tType
> default
> return empty
> end switch
> end file_GetType
>
> function spotlight_Kind someFile
> put spotlight_GetAttribute(someFile, "kMDItemKind") into someKind
> put word 1 to - 1 of someKind into someKind
> delete char 1 of someKind
> delete char -1 of someKind
> return someKind
> end spotlight_Kind
>
> function spotlight_GetAttribute someFile, attributeName
> put spotlight_FileInfo(someFile) into spotlightFileInfo
> return spotlight_ExtractAttribute(spotlightFileInfo, attributeName)
> end spotlight_GetAttribute
>
> function spotlight_FileInfo someFile
> put "mdls" into someShell
> if someFile is not empty then
> shell_BashParamEscape someFile
> put space & someFile after someShell
> end if
> get shell(someShell)
> -- delete line 1 of it
> return line 2 to -1 of it
> end spotlight_FileInfo
>
> function spotlight_ExtractAttribute spotlightFileInfo, attributeName
> if char 1 to 7 of attributeName is not "kMDItem" then put "kMDItem"
> before attributeName
> put "(?im)" & attributeName & " += +(.*)" into someReg
> if matchtext(spotlightFileInfo, someReg, someValue) is true then
> return someValue
> else
> return empty
> end if
> end spotlight_ExtractAttribute
>
> on shell_BashParamEscape @someParam
> put word 1 to -1 of someParam into someParam
> if text_IsQuoted(someParam) is false then
> replace space with ("\" & space) in someParam
> replace "|" with ("\" & "|") in someParam
> end if
> end shell_BashParamEscape
>
> function text_IsQuoted someText
> put "(?m)['" & quote & "]" into someQuote
> put someQuote & ".*" & someQuote & "$" into someReg
> return matchchunk (someText, someReg)
> end text_IsQuoted
>
More information about the use-livecode
mailing list