You pays your money and you takes your pick: Yes, No, Maybe.
It comes down to your definition of 'extension'.
- Is it "anything after the last dot in the name"? If so, those files have no name and are all extension.
- Is it "anything after a dot that isn't the first character in the name"? If so, those files don't have an extension.
- If you use some other definition, then the answer will need to be adjusted accordingly.
Remember that SCCS files used a prefix s.
(amongst others; you'd see p.
files too — and there were many transient file names with other prefixes). Does an SCCS file s.something
have an extension or a prefix? (With s.source.c
, it is reasonably straight-forward; there's a prefix, a name and an extension or suffix, or you could ignore the prefix as a special case and the name is s.source
and the extension is .c
.) What about the default executable name, a.out
? What about a name such as ..dot
; does it have an extension, and if so, what is it?
Note that the answer on DOS was more formalized. There the file system used to enforce (once upon another millennium or so) names with 8.3 and the extension was tangible. But that's a bygone era for the most part (and there are few who miss it).
Anthony Arnold and paxdiablo both noted that names ending with .tar.gz
exist — what's the extension on such files?
If you treat the extension of somecode-8.76.tar.gz
as anything other than .gz
, you are opening yourself up to a bag'o'worms. The contained file is somecode-8.76.tar
; that itself can be reasonably said to have an extension of .tar
. Defining the extension of the whole gzipped tar file as .tar.gz
raises the question of "why isn't it .76.tar.gz
" and also means that you need to revisit the SCCS file naming convention. Absorbing the .76
portion of the name into either .76.tar.gz
or .76.tar
as a suffix is making life complex indeed. It's a valid question, but anything other than "an extension is the string from the last dot to the end of the name" is fraught indeed — or requires interpretation of the meaning of the extension, and gets into another complex area that it generally is better to avoid.
Note that Unix at the O/S or file system level doesn't care about the extension on files. Programs can decide they care about extensions, but that's up to the program. The extension is an indicator of the file type; it is not definitive. That's why the file
program exists to identify the contents of files. It looks at the contents of the file to identify the content; it doesn't pay attention to the file extension (so it doesn't have to decide what the extension is, either).
path extension(const path& p) const;
... if p.filename() contains a dot but does not consist solely of one or to two dots, returns the substring of p.filename() starting at the rightmost dot and ending at the path's end. Otherwise, returns an empty path object." – Stainless.js
extension, but a.htaccess
, for example, is the file itself. – Friedman.htaccess
file with Windows Explorer? It just gives"You must type a file name"
... and it's like that from Win 2000 all the way up to Win 10. I know why I'm sticking to Linux for Webdev ... – Eared.htaccess.
(note trailing dot) and it will accept it, stripping the last dot (trailing dots are not permitted in windows). – Habsburg