dragData["files"] problem

J. Landman Gay jacque at hyperactivesw.com
Fri May 26 00:04:51 EDT 2006


Garrett Hylltun wrote:
> Rev 2.6.1 / OS X
> 
> Greetings,
> 
> I've run into a bit of an odd thing that I can't figure out.  I have a 
> file with the following path:
> 
> /Users/garrett/Desktop/My Music/Metal Rules/Alice In Chains - Man in the 
> box.mp3
> 
> But when I drag and drop it on my app I get the following instead:
> 
> /Users/garrett/Desktop/My Music/Metal Rules/Alice In Chains - Man#88B1F.mp3
> 
> Is there a character length limit on incoming file names for the 
> dragData["files"]?
> 
> Here's the code I am using:

<snip>

Your script is okay, it's the OS X Finder truncating the name. It works 
just as it does on Windows, where you have 8-dot-3 file names that are 
represented as long file names to the user, but stored in the older 
format internally. Revolution resolves these on OS X in most cases, but 
apparently not for drag data.

There is a function "the longFilePath" that allows you to retrieve the 
long file name in Windows. I see it doesn't work in OS X. I think it 
would be a good extension to the language if the longFilePath worked 
identically on both platforms. (Macs didn't have the problem when the 
function was first written, it was a Windows-only thing.) This would be 
a good feature request for Bugzilla.

In the mean time, I've been trying to figure out a graceful way to get 
the long file name and I can't. Here is an ungraceful way:

on dragDrop
   put line 1 of the dragdata["files"] into tPath
   set the itemdel to slash
   set the directory to (item 1 to -2 of tPath)
   put the files into tFiles
   if tPath contains "#" then
     delete char offset("#",tPath) to -1 of tPath
     put line lineoffset(last item of tPath,tFiles) of tFiles into tFile
     put tFile into last item of tPath
   end if
   put cr & tPath after fld 1 -- or process it here
end dragDrop

This will fail completely if:

1. You have two files in the same folder whose first 20 characters are 
identical, differing only by the number following the Finder's # sign.
2. The file name contains a real "#" that isn't a Finder replacement.

Maybe someone else can come up with a better way, or fix this one. Or 
there may be an Applescript function that allows you to get the long name.

I'll enter a feature request into Bugzilla about the longFilePath change.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list