Ok. So to keep testing my code, I commented both methods out. Now I'm
getting the following error on the

GetPathForDisplay method:

Error: Only the first parameter may use the Extends option.

Again...whaaa?

All My Best,
Jeffrey


on 3/21/06 8:45 AM, Harrie Westphal at [EMAIL PROTECTED] wrote:

> 
> On Mar 20, 2006, at 6:02 PM, Jeffrey Ellis wrote:
> 
>> As far as the other issue, I'll post it again. Does anyone know how
>> to not
>> have filenames truncated to 32 characters under OS X?
> 
> The problem with seeing the truncated file names comes from how OS X
> presents the absolutePath string. However, if you use just the name
> property it will always show the proper file name. To get around the
> problem presented by using the AbsolutePath property of the
> folderitem I wrote the following functions as an extensions to the
> FolderItem class. Because they are extensions they must reside within
> a module so that they can be accessed globally. It's going to seem
> like a lot of code, but it executes with good speed and I use it all
> the time.
> 
> Function getPathForDisplay(Extends f As FolderItem) As String
>    // This method walks up the hierarchy of the folderitem passed to it
>    // to form its own version of the absolutepath string, being able to
>    // handle level names longer than 31 characters.
>    Dim parts(-1), goodPath As String
>    Dim fp As FolderItem
> 
>    parts.Insert 0, f.name  // get the file/folder name
>    fp = f
>    Do
>      fp = fp.Parent  // go up one level in the hierarchy
>      parts.insert 0, fp.name  // insert folder/volume name for this
> level
>    Loop Until fp.parent = nil  // if at the volume level we end the loop
>    goodPath = Join(parts,":") // join the parts to make the new path
> string
>    // if this is a directory, and not a bundle add colon to end of
> string, its a folder
>    if f.Directory and not f.isBundle then goodPath = goodPath + ":"
>    return goodPath
> End Function
> 
> Now when you want an AbsolutePath that shows the file name, or
> intervening folder name, that is longer than 31 characters just use a
> statement like the following:
> 
> myAbsolutePath = f.getPathForDisplay
> 
> where you have dimmed myAbsolutePath as a string. The contents of
> myAbsolutePath will have all the proper names in the result.
> 
> You will notice the next to the last line above:
> 
> if f.Directory and not f.isBundle then goodPath = goodPath + ":"
> 
> uses another function to determine if the file being looked at is a
> bundle or not: the code for that method is (watch out for line
> wrapping). However, if you don't care whether or not the path name
> ends with a colon when the item is a folder, you can remove that line
> and ignore the function that follows.
> 
> Function isBundle(Extends f As FolderItem) As Boolean
>    // this method, which was gotten from one of the RB mailing lists
> and was written by someone much more
>    // knowledgable than myself, returns True if the passed in
> folderitem points to a bundle file and false if it
>    // does not
>    dim parentSpec as MemoryBlock
>    dim parentRef as MemoryBlock
>    dim fsRef as MemoryBlock
>    dim fileName as String
>    dim OSError as Integer
>    dim itemInfo as MemoryBlock
>    dim itemFlags as Integer
> 
>    Const kLSRequestBasicFlagsOnly = &h00000004
>    Const kLSItemInfoIsPackage = &h00000002
> 
>    Declare Function FSMakeFSSpec Lib "CarbonLib" (vRefNum as Short,
> dirID as Integer, fileName as PString, spec as Ptr) As Short
>    Declare Function FSpMakeFSRef Lib "CarbonLib" (source as Ptr,
> newRef as Ptr) as Short
>    Declare Function FSMakeFSRefUnicode Lib "CarbonLib" (parentPtr as
> Ptr, nameLength as Integer, name as CString, enc as Integer, outRef
> as Ptr) as Short
>    Declare Function LSCopyItemInfoForRef Lib "CarbonLib" (inItemRef
> as Ptr, inWhichInfo as Integer, outItemInfo as Ptr) as Integer
> 
>    If f.Parent <> nil then //top-level directories probably aren't
> bundles
>      parentSpec = NewMemoryBlock(70)
>      OSError = FSMakeFSSpec(f.MacVRefNum, f.MacDirID, "", parentSpec)
>      If OSError <> 0 then
>        Raise new MacToolboxException("FSMakeFSSpec returned error " +
> Str(OSError))
>      End if
>      parentRef = NewMemoryBlock(80)
>      OSError = FSpMakeFSRef(parentSpec, parentRef)
>      If OSError <> 0 then
>        Raise new MacToolboxException("FSpMakeFSRef returned error " +
> Str(OSError))
>      End if
>      fileName = ConvertEncoding(f.name, Encodings.UTF16)
>      fsRef = NewMemoryBlock(80)
>      OSError = FSMakeFSRefUnicode(parentRef, Len(fileName), fileName,
> 0, fsRef)
>      If OSError <> 0 then
>        Raise new MacToolboxException("FSMakeFSRefUnicode returned
> error " + Str(OSError))
>      End if
> 
>      itemInfo = NewMemoryBlock(24)
>      OSError = LSCopyItemInfoForRef(fsRef, kLSRequestBasicFlagsOnly,
> itemInfo)
>      If OSError <> 0 then
>        Raise new MacToolboxException("LSCopyItemInfoForRef returned
> error " + Str(OSError))
>      End if
>      itemFlags = itemInfo.Long(0)
>      Return Bitwise.BitAnd(itemFlags, kLSItemInfoIsPackage) =
> kLSItemInfoIsPackage
>    Else
>      Return false
>    End if
> End Function
> 
> 
> === A Mac addict in Tennessee ===
> 


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to