Re: pathinfo() function at file.e
- Posted by Jeremy Cowgar <jeremy at c?wgar.com> Apr 29, 2008
- 614 views
Marco Achury wrote: > > pathinfo is simple and nice function. > > In file names as: > FileZilla_3.0.8.1_win32-setup.exe > correctly set extension as exe > > but filenames as: > new.tar.gz > set extension as gz, wich is only > patially truth. hm. I wonder what it should return? for instance, what do you do with a .tar.gz? You normally will gunzip it. Then look at the file again and now you have .tar. I am not sure, I'm open to suggestions as to if .tar.gz should be returned as the extension or if .gz should. > DOS had a real 3 bytes field for extension > in the directory table, but I think that > in modern filesystems the extension concept > has not sense. Even unix system prefer to > have not any extension and prefer magic > numbers for binary and #! for scripts. > > So, finally, I don't find real utility to > the extension field. I prefer that pathinfo > must to return: > On dos and windows 3 fields: drive, path, filename > On Linux/BDS 2 fields: path, filename I beg to differ, the file extension is important. What kind of file am I looking at? .zip? .gz? .html? .txt? They still play a vital role on Linux and Windows/DOS systems. I do think the utility of returning .tar.gz or just .gz can be discussed. Now, also, you can easily derive the filename.ext from pathinfo by concating the two. -- Jeremy Cowgar http://jeremy.cowgar.com