Hi, Joe--
Ah. I don't think he mentioned that.
Ok, I created the method in a new Global Module. However, when run, I'm
still getting the
Error: Only the first parameter may use the Extends option.
In the getPathForDisplay method.
All My Best,
Jeffrey
on 3/21/06 1:40 PM, Joe Huber at [EMAIL PROTECTED] wrote:
> I'm guessing that you may not have put IsBundle in a MODULE??? Since
> it's using Extends, it has to be in a global module so it can extend
> the folderitem class.
>
> Hope this helps,
> Joe Huber
>
>
>> Hi, Joe--
>>
>> Yes, I actually did do that. I defined both methods and pasted them in
>> directly from Harrie's code. :)
>>
>> All My Best,
>> Jeffrey
>>
>>
>> on 3/21/06 11:27 AM, Joe Huber at [EMAIL PROTECTED] wrote:
>>
>>> Harrie's original message, which you copied, includes a specific
>>> description of this issue.
>>>
>>> isBundle is another method you need to define with the code he
>>> provided in the second part of his message.
>>>
>>> Regards,
>>> Joe Huber
>>>
>>>
>>>> Wow... Thank you. This looks great :)
>>>>
>>>> Ok. I copied and pasted everything exactly as written. But I am getting a
>>>> very strange error.
>>>>
>>>> At this line:
>>>>
>>>>
>>>> if f.Directory and not f.isBundle then goodPath = goodPath + ":"
>>>>
>>>>
>>>> I am getting that the isBundle method doesn't exist.
>>>>
>>>> I checked and re-checked the method, which I created as part of the parent
>>>> window, just like the getPathForDisplay method. I then copied the name
>>>> from
>>>> that same line of code, just to be sure, and renamed the method by pasting
>>>> -- not that anything changed. Again, I got the same error.
>>>>
>>>> I'm stumped...
>>>>
>>>> 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>
>>>
>
_______________________________________________
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>