PDA

View Full Version : Windows Localizations cause File.Find to act differently?


jassing
09-12-2008, 04:02 PM
Has anyone spotted any situation where a windows localization caused File.Find() to act differently?

I was helping someone in Norway clean up old shortcuts.

The code I used is posted below for peer-review.

He reported that *ALL* his shortcuts were removed, but not the folders...

The only way I can think of this happening is file.find() returned a list of all files...

Since I was doing this gratis, I did only cursory tests; which didn't yeild any problems, but it was not on a norway windows. I do not know what his version of windows was; but from the screen shot he sent; it appeared to be XP.

He's obviously (and understandably) rather miffed (****ed?); regardless of if he wants me to help him further; I want to know what went wrong....


Global Functions
Custom={};

function Custom.RemoveMyOldShortcuts( cFolder, bKeepFolder )
local tShortcuts = File.Find(cFolder, "Embla Familie og Slekt*.lnk", true, true);
if tShortcuts then
local x;
for x = 1, Table.Count(tShortcuts) do
File.Delete(tShortcuts[x], false, false, false);
if not bKeepFolder then
Folder.Delete( String.PathOnly( tShortcuts[x] ) );
end
end
end
local tFolders = Folder.Find(cFolder, "Embla Familie og Slekt*", true);
if tFolders then
local x;
for x = 1, Table.Count(tFolders) do
Folder.Delete( tFolders[x] );
end
end
end



function String.PathOnly( cFQP )
local tParts = String.SplitPath(cFQP);
local cReturn = tParts.Drive..tParts.Folder;
if String.Right(cReturn,1)=="\\" then
cReturn = String.Left(cReturn,String.Length(cReturn)-1);
end
return cReturn;
end

On Pre Install
-- Remove From various locations
Custom.RemoveMyOldShortcuts( Shell.GetFolder(SHF_DESKTOP) );
Custom.RemoveMyOldShortcuts( Shell.GetFolder(SHF_DESKTOP_COMMON) );
Custom.RemoveMyOldShortcuts( Shell.GetFolder(SHF_STARTMENU) );
Custom.RemoveMyOldShortcuts( Shell.GetFolder(SHF_STARTMENU_COMMON) );
Custom.RemoveMyOldShortcuts( Shell.GetFolder(SHF_STARTMENUPROGRAMS) );
Custom.RemoveMyOldShortcuts( Shell.GetFolder(SHF_STARTMENUPROGRAMS_COMMON) );
Custom.RemoveMyOldShortcuts( Shell.GetFolder(SHF_DESKTOP) );
Custom.RemoveMyOldShortcuts( Shell.GetFolder(SHF_APPLICATIONDATA) .. "\\Microsoft\\Internet Explorer\\Quick Launch", true );
Custom.RemoveMyOldShortcuts( Shell.GetFolder(SHF_APPLICATIONDATA_LOCAL) .. "\\Microsoft\\Internet Explorer\\Quick Launch", true );
Custom.RemoveMyOldShortcuts( Shell.GetFolder(SHF_APPLICATIONDATA_COMMON) .. "\\Microsoft\\Internet Explorer\\Quick Launch",true );

jassing
09-13-2008, 05:46 AM
I see the error in my ways -- what I sent out was not what I tested..
file.find -- true,false

Not sure how that got changed....