Re: (no subject) or DIR()

new topic     » topic index » view thread      » older message » newer message

Pete Lomax wrote:
> 
> On Sat, 24 Jun 2006 15:11:22 -0700, Sergio Gelli
> <guest at RapidEuphoria.com> wrote:
> 
> >Euman wrote:
> >> I wrote along time ago a replacement for dir()
> >> <a
> >> href="http://www.rapideuphoria.com/dir232.zip">http://www.rapideuphoria.com/dir232.zip</a>
> 
> There is another one here:
> <a
> href="http://www.listfilter.com/cgi-bin/esearch.exu?fromMonth=C&fromYear=A&toMonth=C&toYear=A&postedBy=Lomax&keywords=FINDDATA">http://www.listfilter.com/cgi-bin/esearch.exu?fromMonth=C&fromYear=A&toMonth=C&toYear=A&postedBy=Lomax&keywords=FINDDATA</a>
> If you read through the thread (by clicking on the message header),
> Chris added an update for win32lib which should practically run
> stand-alone; if you hit problems drop me your email address and I'll
> send you something I know works standalone.
> 
> Regards,
> Pete
> 
> 
Hi Pete,

just a note for your FINDDATA routine: get_file_ext(sequence filename).

Although generally correct, with "normal" path names and any file, 
I have met in my life a [perfectly legal] path like:

D:\root\folder\sub.directory\

What happens then when a simple filename without any extension is read 
from there?
Therefore I have changed my getFileExt( ) routine as follows:

global function getFileExt( sequence filestr)
integer y

	y = length( filestr)
	if not y then
		return ""
	end if
	while filestr[y]!= '.' do
		
		-- the dot inside a path does not delimit a file type
		if find( filestr[y], {'\\', '/'}) then          
			y = 1 
		end if
		y-= 1
		if y = 0 then return "" end if
	end while

	-- use the Derek's routine, that should be faster
	return lower( filestr[y +1..$])                     

end function


Perhaps this can be useful.
antonio

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu