Page 1 of 1

Short File name

Posted: Fri Mar 15, 2019 11:37 am
by loulou2522
How can i translate a long file name (more than 14 characters) to a short File name ?
example TOTO123456787890 to toto12~1
thanks

Re: Short File name

Posted: Fri Mar 15, 2019 12:05 pm
by CELTIC88
hi ;)

https://docs.microsoft.com/en-us/window ... tpathnamew

Code: Select all

spath.s{300}
GetShortPathName_(#PB_Compiler_Home +"Examples\Sources\Data\CdPlayer.ico",@spath,300)

Debug spath

Re: Short File name

Posted: Fri Mar 15, 2019 12:06 pm
by Kiffi
search for 'GetShortPathName_'

Re: Short File name

Posted: Fri Mar 15, 2019 3:53 pm
by ts-soft
Attention:
https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getshortpathnamew wrote:This outcome is also possible with NTFS volumes because there's no guarantee that a short name will exist for a given long name.

Re: Short File name

Posted: Fri Mar 15, 2019 5:30 pm
by TI-994A
ts-soft wrote:Attention:
https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getshortpathnamew wrote:This outcome is also possible with NTFS volumes because there's no guarantee that a short name will exist for a given long name.
To check if the file system supports the 8dot3 specification (dir /x):

Code: Select all

C:\>dir /x
Volume in drive C is xxxxxxxx
Volume Serial Number is xxxx-xxxx

Directory of C:\Program Files\PureBasic\Examples\Sources - Advanced\Atomic FTP Server

19/12/2018  08:04 PM    <DIR>                           .
19/12/2018  08:04 PM    <DIR>                           ..
09/07/2014  11:20 AM             5,132   ATOMIC~1.PB    Atomic FTP Server.pb
19/12/2018  08:04 PM    <DIR>                           FTP
06/10/2007  01:33 PM               944                  Readme.txt
To enable the 8dot3 specification (replace "D" with target drive letter):

Code: Select all

C:\>fsutil 8dot3name set D: 0
It should be noted that only files created henceforth will maintain the 8dot3 file names.