Just change line 5 to this:
+ fileName.substr (0,10) + ((fileName.length> 10)? '...': '')
in English:
fileName.substr(0,10): first 10 characters of the file name; if the file name is shorter than 10 characters .substr()will have no effect.
((fileName.length > 10)?'...':''): if the file name is really longer than 10 characters, print '...'.
source
share