XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently 2017年 Sep 23日 19:19

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: 2017年 May 27日 03:23 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 556
There is a bug in the Xwidget getFileList function when used in non-recursive mode that means it fails to report the subfolders contained within a folder. So, if you have a folder with no files within, but does have four sub-folders within then Xwidget fails to return the folders at all instead reporting an empty folder.

The Yahoo widget engine reports folders and files correctly.

This function mimics the yahoo widget engine filesystem.getDirectoryContents function and it uses a combination of Xwidget and activeX functionality to get a file list with folder information when asked to get a listing in non-recursive mode.

validTypes is a variable list that contains a list of valid file types, it needs to be defined globally, eg.
Code:
var validTypes = ["mpeg","mp4","m4a","mpg","flv","mp3","aac","wav","wma","aif","aiff","au","snd"];  //array


Code:
//=================================
// Function to count the folder contents folder by folder
//=================================
function filesystemGetDirectoryContents(folderspec, recursiveBoolean){
var fso, f, fc, fs, s;
  if ( recursiveBoolean == false ) {
    fso = new ActiveXObject("Scripting.FileSystemObject");
    f = fso.GetFolder(folderspec);
    colFiles  = f.SubFolders;
    fc = new Enumerator( colFiles );

    s = "";
    for (; !fc.length; fc.moveNext()) {
        if (fc.item() == null) {
           break;
        }
        s += fc.item();
        s += "|";
    }
    // now we have the folders - add to the file list
    fs = getFileList(folderspec,validTypes,false);
    s = s + fs;
  } else {
    //the xwidget getfilelist does not return an array but a bar-separated list
    s = getFileList(folderspec,validTypes,true);
  }
  // convert the filelist into an array
  s = s.split('|');
  return s;
}
//=================================
// end function
//=================================



This code successfully fixes Xwidget's faulty getFileList functionality.

It is used in this sense:

Code:
//get the sub-folder list
 paths = filesystemGetDirectoryContents(path, false)  ;


Naming the new function FilesystemGetDirectoryContents means that any conversion of an Yahoo widget that uses the filesystem.getDirectoryContents code is much easier. These type of translated functions can be added to any Xwidget and the simple removal of a '.' will make the old yahoo widget code compatible.


Top
 Profile  
 
PostPosted: 2017年 Jun 6日 11:40 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 556
I have added a small widget that demonstrates the above issue and how the ActiveX control is used to provide a workaround.

Jim, this could have been raised as a bug, as a folder list that reports nothing when there are folders in the directory certainly appears as a bug to me. I have provided a workaround in activeX but Tony could take note of these enhancements/workarounds and factor them into a revised Xwidget 1.9.

Image


Attachments:
File comment: sample widget
filesystemGetDirectoryContents.xwp [26.17 KiB]
Downloaded 12 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group