[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

8.3 Filename Format

How can I determine the 8.3 name of file from the long name? For that I need to communicate with the DOS-compatible FAT, right? How do I do that?
0
Lescha
Asked:
Lescha
  • 6
  • 3
  • 2
  • +2
1 Solution
 
nil_dibCommented:
long:  abcdefghi_1.xyz
8.3:   abcdef~1.xyz

nil_dib

0
 
ZoppoCommented:
which OS?

In Windows you can use GetShortPathName() API function.

ZOPPO
0
 
nietodCommented:
Zoppo, of course for for windows!  GetShortPathName() is the answer.  You should lock the question.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ZoppoCommented:
Nietod, what if he wants to try to handle filenames created by i.e. Win95 on a FAT partition using a MS-DOS programm, i.e. if he can read the filenames 'LongFileName1.xxx' and 'LongFileName2.xxx' from a text file and needs to find out if 'LongFileName1.xxx' is 'LongFi~1.xxx' or 'LongFi~2.xxx' ???
0
 
nietodCommented:
I think that is far fetched....but possible, I suppose...Your points, your choice.
0
 
ZoppoCommented:
ok, ok, let's try ...

answer is (or might be): GetShortPathName()

ZOPPO

BTW, it's not a matter of course one is as fair as nietod telling me to lock the question instead of locking it himself. A really laudable, honorable trait :))
0
 
nietodCommented:
I just want ti minimise any opportunity for a dispute to arrise.  Somone else could have come along and answer and then....
0
 
GastonCommented:
::FindFirstFile and ::FindNextFile return a WIN32_FILE_DATA struct, that contains in one of it's members the short name.
Go for it !
0
 
nietodCommented:
There doesn't seem to be any advantage to using FindFirstFile().  It should be less efficient (slower) Any you have more work to do as you have to close then find handle.
0
 
LeschaAuthor Commented:
Guys,

What I want to do is this:

when I use DIR command under DOS from Win95, I get the list that has both 8.3 names and long names. I want to get exactly the 8.3 names from that list.

However, if I use DIR command from 'Previous DOS mode' (6.22 in my case) I might get different 8.3 names. But this is irrelevant, because a program using any WinAPI function is not runnable under non-Win95 DOS, am I right?

In any case, the program is for Win95, so Zoppo's answer should work. I'll try it and grade the answer.

Thanks.
0
 
nietodCommented:
>>  if I use DIR command from 'Previous DOS mode'
>> (6.22 in my case) I might get different 8.3 names.
No.  The names will be the same.  Windows (x stores the 8.3 file name in the FAT system that DOS "understands" and then stores the long filename elsewhere, so DOS will see the same 8.3 name that windows uses.
0
 
LeschaAuthor Commented:
nietod,

well, it's a fact that I have a CD on which the directories, when under 6.22, show, for instance, DESIGN~1 (for "Designated"), while Win95 DOS shows me something like DESIGN~5, or smth like it.

And don't tell me it's a bug ;)

Have you heard the one about Microsoft selling times for commercials in their Windows Bug Reports?
0
 
nietodCommented:
I've never seen that happen with a any type of drive.  But it is a little more likely with a CD because a CD does not use FAT, so DOS does not have built-in features to read file infor from the CD.  This is handled by the CD driver.  However, I'm still a little surprised that this could happen.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 6
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now