Re: file extensions
- Posted by Jacques Deschenes <desja at GLOBETROTTER.QC.CA> Aug 12, 1997
- 876 views
At 12:27 12-08-97 -0400, you wrote: >---------------------- Information from the mail header ----------------------- >Sender: Euphoria Programming for MS-DOS <EUPHORIA at >MIAMIU.ACS.MUOHIO.EDU> >Poster: "Vikas B. Patel" <patelv at EROLS.COM> >Subject: file extensions >------------------------------------------------------------------------------- > >Hello, > I need a Euphoria routine to get the extension of a file. Any ideas? >Thanks, >Vikas B. Patel Here is a function that separate the components of a file name. function SplitPath(sequence path) -- split path to its constituants: directory, name, extension -- return {directory, name, extension} sequence dir, name, ext integer pos, l l = length(path) pos = find('\\',reverse(path)) if pos = 0 then dir = "" name = path else dir = path[1..l-pos+1] name = path[l-pos+2..l] end if pos = find('.',name) if pos then name = name[1..pos-1] ext = name[pos..length(name)] else ext = "" end if return {dir,name,ext} end function -- SplitPath() ----------------------------------- Jacques Deschenes Baie-Comeau, Quebec Canada desja at globetrotter.qc.ca