love.filesystem.deltree

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Centauri Soldier
Prole
Posts: 42
Joined: Mon May 21, 2012 6:38 am

Re: love.filesystem.deltree

Post by Centauri Soldier »

Hey, just wanted to stop by and say thanks, Roland_Yonaba. String manipulation has always been my weakness in lua. I have read tutorials, seen examples and still it gave me trouble. But after seeing your example, I spent a few hours buried in my hard copy of the Lua Reference Manual and playing with code and now I think I've got it. Your example triggered something in my brain that no other example has so I wanted to say 'Thanks'...so thanks :awesome:!
User avatar
Centauri Soldier
Prole
Posts: 42
Joined: Mon May 21, 2012 6:38 am

Re: love.filesystem.deltree

Post by Centauri Soldier »

This version will account for underscores in the file name and extension.

Code: Select all

function love.filesystem.getFileType(sFile)
local sRet = "";
local sFileRev = string.reverse(sFile);
local nPoint = string.find(sFileRev, "[.%..]");

	if nPoint then
	sRet = string.sub(sFile, string.len(sFile) - nPoint + 1);
	end
	
return sRet
end
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 89 guests