This may be a very simple question to many of you but I wanted to get some advice on what I am trying to do. Please bear with me for a sec. =)
Right now, I am simply trying to first know whether the file name that the user provided is a short name or a long name.
If it is a short name, I want to convert it to long file name.
Yet, I have a few restriction for this job. I am required to use calls in NTDLL and the way I convert is to call NtQueryDirectory and loop through the listing to get a short name and a long name and then convert it accordingly.
But this incurs lots of overhead and I wanted to know if there can be any better way to accomplish what I am trying to do now.
Please give me some advice and I thank you in advance.
Why not specify the filename in NtQueryDirectory so that you do not have to
search the entire directory? You should also use
FileBothDirectoryInformation - this will return long and short name
information for the file.
Microsoft should abolish shortname support. It’s been at least ten years
since this crap has been obsolete.
On Jan 11, 2008 9:37 AM, wrote:
> Hi Everyone, > > This may be a very simple question to many of you but I wanted to get some > advice on what I am trying to do. Please bear with me for a sec. =) > > Right now, I am simply trying to first know whether the file name that the > user provided is a short name or a long name. > If it is a short name, I want to convert it to long file name. > > Yet, I have a few restriction for this job. I am required to use calls in > NTDLL and the way I convert is to call NtQueryDirectory and loop through the > listing to get a short name and a long name and then convert it accordingly. > > But this incurs lots of overhead and I wanted to know if there can be any > better way to accomplish what I am trying to do now. > Please give me some advice and I thank you in advance. > > YEH > > — > NTDEV is sponsored by OSR > > For our schedule of WDF, WDM, debugging and other seminars visit: > http://www.osr.com/seminars > > To unsubscribe, visit the List Server section of OSR Online at > http://www.osronline.com/page.cfm?name=ListServer >
Thank you Rodday.
In fact, I was wrong in my description. I do specify filename to get what I want but I assumed that this is done via some kind of loop within NtQueryDirectoryFile().
Sorry for wrong data.
So for now, if I can at least somehow know if the filename is a long name, I do not have to do all this hassle. If there is such a way, please kindly let me know.
Otherwise, I will probably check out the length of file name and then call NtQueryDirectory() if it is longer than 11 characters.
Thanks.
If you have a filename the following are the rules for what you can
determine just by looking at the string.
Short filename:
You can know a string is NOT a short filename
You cannot know a string is a short filename
Long filename:
You can know a string is a long filename
You cannot know a string is not a long filename
You must query to see if the names returned for SFN & LFN matches your
string to know which one it is. If SFN generation is disabled on NTFS, then
you can know that all names are LFNs.
wrote in message news:xxxxx@ntdev… > Thank you Rodday. > In fact, I was wrong in my description. I do specify filename to get what > I want but I assumed that this is done via some kind of loop within > NtQueryDirectoryFile(). > Sorry for wrong data. > > So for now, if I can at least somehow know if the filename is a long name, > I do not have to do all this hassle. If there is such a way, please kindly > let me know. > Otherwise, I will probably check out the length of file name and then call > NtQueryDirectory() if it is longer than 11 characters. > Thanks. > > YEH > >
> If SFN generation is disabled on NTFS, then you can know that all names
are LFNs.
Can you really? I haven’t tested it, but won’t there still be valid short
names for files created before short name generation was disabled?
http://support.microsoft.com/kb/210638 says: “NOTE: Existing files using the
short name format will still be available to 32-bit programs, but all files
created after this change is implemented will be unavailable to older 16-bit
programs.”
Dan.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David Craig
Sent: Friday, January 11, 2008 10:39 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] short file name to long file name
If you have a filename the following are the rules for what you can
determine just by looking at the string.
Short filename:
You can know a string is NOT a short filename 2. You cannot know a
string is a short filename
Long filename:
You can know a string is a long filename 2. You cannot know a string is
not a long filename
You must query to see if the names returned for SFN & LFN matches your
string to know which one it is. If SFN generation is disabled on NTFS, then
you can know that all names are LFNs.
wrote in message news:xxxxx@ntdev… > Thank you Rodday. > In fact, I was wrong in my description. I do specify filename to get > what I want but I assumed that this is done via some kind of loop > within NtQueryDirectoryFile(). > Sorry for wrong data. > > So for now, if I can at least somehow know if the filename is a long > name, I do not have to do all this hassle. If there is such a way, > please kindly let me know. > Otherwise, I will probably check out the length of file name and then > call > NtQueryDirectory() if it is longer than 11 characters. > Thanks. > > YEH > >
If you look at the valid character and formatting rules for short file names
you can get a fairly good idea if the name could be a short file name. If
it could be a short name there is a real good chance it is a short name, and
also a long name, since they will be equivalent.
The general rules are something like (but check this!):
<= 8 characters in name base
no more than one dot
<= 3 characters after dot
no internal spaces
all uppercase
There are also a bunch of excluded special character rules.
In general if the name has spaces or lowercase, it is NOT a short name.
Interesting, I have never tried it. I would have hoped that NTFS would
ignore any SFNs left from before the they were disabled. Guess I was
expecting too much. I have never used that option since I like SFNs. I
wonder if a directory entry is updated, does NTFS drop the SFN if they are
globally disabled? Interesting question that is rather easy to determine,
but I guess I don’t care that much.
“Dan Kyler” wrote in message news:xxxxx@ntdev… >> If SFN generation is disabled on NTFS, then you can know that all names > are LFNs. > > Can you really? I haven’t tested it, but won’t there still be valid short > names for files created before short name generation was disabled? > > http://support.microsoft.com/kb/210638 says: “NOTE: Existing files using > the > short name format will still be available to 32-bit programs, but all > files > created after this change is implemented will be unavailable to older > 16-bit > programs.” > > - Dan. > > -----Original Message----- > From: xxxxx@lists.osr.com > [mailto:xxxxx@lists.osr.com] On Behalf Of David Craig > Sent: Friday, January 11, 2008 10:39 AM > To: Windows System Software Devs Interest List > Subject: Re:[ntdev] short file name to long file name > > If you have a filename the following are the rules for what you can > determine just by looking at the string. > > Short filename: > 1. You can know a string is NOT a short filename 2. You cannot know a > string is a short filename > > Long filename: > 1. You can know a string is a long filename 2. You cannot know a string > is > not a long filename > > You must query to see if the names returned for SFN & LFN matches your > string to know which one it is. If SFN generation is disabled on NTFS, > then > you can know that all names are LFNs. > > wrote in message news:xxxxx@ntdev… >> Thank you Rodday. >> In fact, I was wrong in my description. I do specify filename to get >> what I want but I assumed that this is done via some kind of loop >> within NtQueryDirectoryFile(). >> Sorry for wrong data. >> >> So for now, if I can at least somehow know if the filename is a long >> name, I do not have to do all this hassle. If there is such a way, >> please kindly let me know. >> Otherwise, I will probably check out the length of file name and then >> call >> NtQueryDirectory() if it is longer than 11 characters. >> Thanks. >> >> YEH >> >> > > > > — > NTDEV is sponsored by OSR > > For our schedule of WDF, WDM, debugging and other seminars visit: > http://www.osr.com/seminars > > To unsubscribe, visit the List Server section of OSR Online at > http://www.osronline.com/page.cfm?name=ListServer > >
If you disable long filename generation via KB210638, you should also immediately apply KB896427. I disabled LFNs quite a while ago, considering them outdated and just taking up processing time and disk writes. Then I started having networking problems left and right and spent quite some time before finding KB896427 (which is necessary for XP SP1/SP2 and 2K3) - since it’s *not* available through Windows Update.
SFN - I assume you meant disabled SFN not LFN. Odd that the docs for
KB210638 do not reference KB896427 and vice versa.
The idiocy of keeping 16bit compat on 64bit system is beyond my
understanding.
On Jan 11, 2008 7:26 PM, wrote:
> I’ll chime in here: > > If you disable long filename generation via KB210638, you should also > immediately apply KB896427. I disabled LFNs quite a while ago, considering > them outdated and just taking up processing time and disk writes. Then I > started having networking problems left and right and spent quite some time > before finding KB896427 (which is necessary for XP SP1/SP2 and 2K3) - since > it’s not available through Windows Update. > > -Stephen Cleary > > — > NTDEV is sponsored by OSR > > For our schedule of WDF, WDM, debugging and other seminars visit: > http://www.osr.com/seminars > > To unsubscribe, visit the List Server section of OSR Online at > http://www.osronline.com/page.cfm?name=ListServer >
> The idiocy of keeping 16bit compat on 64bit system is beyond my
understanding.
Because sometimes you have to create/edit files that will be used by
SFN-only systems. There are a number of MP3 players and animation players
in the market that for one reason or another (usually the underlying mini-OS
or historical reasons) can’t deal with anything but 8.3. The host may have
an app that needs to build filename references. So it better know what the
file name is going to be.
Using SFNs on the desktop is pretty rediculous. But that doesn’t mean that
you might not be dealing with some other system and have to move files back
and forth.
On Jan 13, 2008 4:33 AM, Loren Wilton wrote: > SFN-only systems. There are a number of MP3 players and animation players > in the market that for one reason or another (usually the underlying mini-OS > or historical reasons) can’t deal with anything but 8.3. The host may have
Digital cameras and MP3 players that typically store huge files, have no reason to leap to FAT32 willy-nilly. The overhead of small clusters (or rather the resulting huge FAT tables!) is substantial.
If the devices cache the FAT table, then they end up wasting RAM as well (increase in RAM means more juice is required). Too bad MS put an artificial low cap on cluster size. (To such an extent that the XP/2003 format utility is now unable to complete formating a device given the largest possible FAT16 cluster size)
There is also the question of licensing FAT32. I believe MSFT owns the patent.
wrote in message news:xxxxx@ntdev… > Hi Everyone, > > This may be a very simple question to many of you but I wanted to get some advice on what I am trying to do. Please bear with me for a sec. =) > > Right now, I am simply trying to first know whether the file name that the user provided is a short name or a long name. > If it is a short name, I want to convert it to long file name. > > Yet, I have a few restriction for this job. I am required to use calls in NTDLL and the way I convert is to call NtQueryDirectory and loop through the listing to get a short name and a long name and then convert it accordingly. > > But this incurs lots of overhead and I wanted to know if there can be any better way to accomplish what I am trying to do now. > Please give me some advice and I thank you in advance. > > YEH >
“Loren Wilton” wrote in message news:xxxxx@ntdev… > If you look at the valid character and formatting rules for short file names > you can get a fairly good idea if the name could be a short file name. If > it could be a short name there is a real good chance it is a short name, and > also a long name, since they will be equivalent. > > The general rules are something like (but check this!): > > <= 8 characters in name base > no more than one dot > <= 3 characters after dot > no internal spaces > all uppercase > There are also a bunch of excluded special character rules. > > In general if the name has spaces or lowercase, it is NOT a short name. > > Loren > > >
There are definitely UM functions to validate the characters in a putative
short file name, and to convert from long to short or short to long. I
would assume that some of this functionality is available in KM, but since
I’ve never had to do it there I’ve never looked.
“Loren Wilton” wrote in message > news:xxxxx@ntdev… >> If you look at the valid character and formatting rules for short file >> names >> you can get a fairly good idea if the name could be a short file name. >> If >> it could be a short name there is a real good chance it is a short name, >> and >> also a long name, since they will be equivalent. >> >> The general rules are something like (but check this!): >> >> <= 8 characters in name base >> no more than one dot >> <= 3 characters after dot >> no internal spaces >> all uppercase >> There are also a bunch of excluded special character rules. >> >> In general if the name has spaces or lowercase, it is NOT a short name. >> >> Loren >> >> >> > > > — > NTDEV is sponsored by OSR > > For our schedule of WDF, WDM, debugging and other seminars visit: > http://www.osr.com/seminars > > To unsubscribe, visit the List Server section of OSR Online at > http://www.osronline.com/page.cfm?name=ListServer
> There are definitely UM functions to validate the characters in a putative
short file name, and to convert from long to short or short to long. I
would assume that some of this functionality is available in KM, but since
I’ve never had to do it there I’ve never looked.