www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - What is the extension of ".pdf"

reply Andre Pany <andre s-e-a-p.de> writes:
Hi,
I try to solve the puzzle 
https://www.codingame.com/training/easy/mime-type but have some 
issue because std.path:extension returns null for file name 
".pdf" while the puzzle (test case 3) expects that the extension 
is ".pdf".

Is the puzzle wrong or the phobos extension implementation?

Kind regards
Andre
Oct 04 2019
parent reply mipri <mipri minimaltype.com> writes:
On Friday, 4 October 2019 at 19:58:16 UTC, Andre Pany wrote:
 Hi,
 I try to solve the puzzle 
 https://www.codingame.com/training/easy/mime-type but have some 
 issue because std.path:extension returns null for file name 
 ".pdf" while the puzzle (test case 3) expects that the 
 extension is ".pdf".

 Is the puzzle wrong or the phobos extension implementation?
The implementation is very likely thinking of Unix dotfiles, like .bash_profile, where the intent is to hide the file from normal displays rather than suggest an extension. I don't see a mention of dotfiles in the source, but it has these tests: assert(extension(".foo".dup).empty); assert(extension(".foo.ext"w.dup) == ".ext");
 Kind regards
 Andre
Oct 04 2019
parent Andre Pany <andre s-e-a-p.de> writes:
On Friday, 4 October 2019 at 20:12:47 UTC, mipri wrote:
 On Friday, 4 October 2019 at 19:58:16 UTC, Andre Pany wrote:
 Hi,
 I try to solve the puzzle 
 https://www.codingame.com/training/easy/mime-type but have 
 some issue because std.path:extension returns null for file 
 name ".pdf" while the puzzle (test case 3) expects that the 
 extension is ".pdf".

 Is the puzzle wrong or the phobos extension implementation?
The implementation is very likely thinking of Unix dotfiles, like .bash_profile, where the intent is to hide the file from normal displays rather than suggest an extension. I don't see a mention of dotfiles in the source, but it has these tests: assert(extension(".foo".dup).empty); assert(extension(".foo.ext"w.dup) == ".ext");
Thanks a lot for the explanation, yes, that make sense. Kind regards Andre
Oct 05 2019