I Figured it Out!


This is more for the developers out there following my blog…
 
Well, it turns out that the API (application programming interface) that I was using for detecting the files that were dragged to The Magic Folder gadget would not detect the extension if they were turned off. This is why the introduction screen advised you to turn on file extensions. Until a recent comment on my gadget page I NEVER thought of revisiting this UNTIL now. I have found some "unique" workarounds to limitations in the Gadget API sets over the last couple of months and the workaround to the file extensions issues was so incredibly simple that I am smacking myself for not trying it before now.
 
Windows Scripting File System Object has the basic solution:
 

// get the first file from the dragged file items using the System.Shell
// API for Vista Sidebar Gadgets.
var oFile = System.Shell.itemFromFileDrop(event.dataTransfer, 1);
// get an FSO object, then get the file from the path passed by the
// Gadget API …
var fso = new ActiveXObject("Scripting.FileSystemObject");
var filItem = fso.GetFile(oFile.path);
// Now get the file extension from it
var start = instrrev(filItem.Path,".");
var
len = filItem.Path.length – start;
var filExt = new String(filItem.Path.substr(start,len));

It was actually very simple to pull this solution inline with what is already created. Along with a few smaller updates – including an overhaul of the Introduction Screen, which has the instructions for turning ON file extensions yanked – version 1.6 is currently undergoing my test pass and I hope to get it posted first thing in the morning.

A big thank you to ctshiner whoever and wherever you are…you woke me up.

One thought on “I Figured it Out!

  1. I realize this is bringing up ancient history, but while doing a totally pointless google of my preferred online identity (ctshiner) I came across this.  Never did I expect an idle remark of mine to actually merit discussion somewhere : D  Anyway, it just made me smile, and of course, you\’re welcome!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s