Posted by member 248213 on 2007-07-02 07:52:11 link

"the image path the same as the icons path"
So the .icon overlay has "Icon firefox.png"?
Well, then it will display the icon for png files.

Because they are independant (1 for images, 1 for the rest) you need a way to figure out what the resource is being changed to.

So, what is different about the resource? How can we tell them apart?
File extensions are how the OS differs files, so that would be a safe bet.

The extension can be defined by "Anything after the last point/fullstop" eg; "blah.extension"

Ok, so how can we detect a file extension?
"Regular expressions" (or "patterns" in lua) can parse any string according to a set of rules.
So you can form a regexp (or pattern) that means "Return Anything after the last point/fullstop"

I use this code for lua:
local ext = string.match(filepath,".*[/\\/.](.*)")
if ext == nil then
return "unknown"
else
return string.lower (ext)
end

The first line defines a local variable "ext" whos value will be set to a match in the string "filepath".
The rules of the match (the pattern), in english are something like: "After any amount of characters(.*) and after a backslash[/\\ and a fullstop/.] find any number of characters and return them as the result(.*)"
Whew! :D

The second checks if anything was grabbed (maybe trying to find the extension for "C:\folder\filename" which has no extension)

The fifth line just makes it lower case for easy checking (eg; PNG != png)


You should go with lua. Its not too rough, and lots of themers here (and @ ls-themes.org) use it