Getting the type code of a file under OSX
Joel Guillod
joel.guillod at net2000.ch
Sun Jul 31 03:36:21 EDT 2005
Ken,
Why do you bother with the second parameter pType? Just drop it and
change the following from:
put urlEncode(last item of pFilePath) into tItem
delete last item of pFilePath
put the directory into tOldDir
set the directory to pFilePath
if pType = "file" then
put the detailed files into tDetailedList
else
put the detailed folders into tDetailedList
end if
to:
put there is a file pFilePath into tIsFile -- new script line
put urlEncode(last item of pFilePath) into tItem
delete last item of pFilePath
put the directory into tOldDir
set the directory to pFilePath
if tIsFile then -- modified script line
put the detailed files into tDetailedList
else
put the detailed folders into tDetailedList
end if
then the first line of your function is simply:
function stsFileInfo pFilePath
and that's it!
Cheers,
Joel
> [...]
>
> on mouseUp
> answer file "Get a file:"
> if it <> "" then
> put stsFileInfo(it,"file") into tDocInfoA
> put tDocInfoA["creatorType"]
> end if
> end mouseUp
>
> If I selected a Word document, this would return "MSWDW8BN".
>
> ----------------------------------------------------------------------
> --| FUNCTION: stsFileInfo
> --|
> --| Author: Ken Ray
> --| Version: 1.0
> --| Created: 3/4/04
> --| Last Mod: --
> --| Requires: --
> --|
> --| Retrieves the file/folder information on a specific file/folder
> in a
> parseable array
> ----------------------------------------------------------------------
>
> function stsFileInfo pFilePath,pType
> -- supports keys of
> "full,fileName,dataSize,resSize,createDate,modDate,accessDate,BUdate,o
> wnerID
> ,groupID,permissions,creatorType,Size"
> set the itemDel to "/"
> put urlEncode(last item of pFilePath) into tItem
> delete last item of pFilePath
> put the directory into tOldDir
> set the directory to pFilePath
> if pType = "file" then
> put the detailed files into tDetailedList
> else
> put the detailed folders into tDetailedList
> end if
> [...]
More information about the use-livecode
mailing list