Do dotfiles, such as .htaccess
.gitignore
and .config
, have a file extension and no filename or are they considered to have a filename and no extension?
I'm trying to implement some utility functions in PHP, which is notorious for doing things wrong and I noticed that PHP's pathinfo
function considers dotfiles to have a file extension and no filename, whereas node's path.extname
considers dotfiles to have a filename and no extension.
I'm unclear as to whether a standard exists, or whether this amounts to developer preference.
How to open a DOT file. You can open DOT files with Microsoft Word in Windows and macOS. The word processor is also available for Android and iOS devices, but only the iOS version supports DOT files. Other word processors can also open DOT files but they may not fully support the formatting of the original templates.
dot file is the Microsoft Word template that is used to store the default settings such as font, font size, content of a file, etc. It is used with each of the Microsoft Word files you open.
You pays your money and you takes your pick: Yes, No, Maybe.
It comes down to your definition of 'extension'.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With