Article View: comp.os.ms-windows.programmer.misc
Article #1927Re: buffer sizes for filenames, pathnames etc.
From: Chris Marriott
Date: Thu, 31 Dec 1992 19:39
Date: Thu, 31 Dec 1992 19:39
71 lines
3396 bytes
3396 bytes
In article <1992Dec31.013722.18655@emr1.emr.ca> jagrant@emr1.emr.ca writes:
>Ok, somebody explain this...
> [ stuff deleted]
>
>Now it seems to me that there should only have to be one definition
> #define MAX_LENGTH_PATHNAME ??
>regardless of whether or not we are using DOS or Windows.
>This is the size of the buffer required to hold the longest possible
>pathname, including drive, directory, filename and extension.
>
>As noted above, there are several defined constants and 3 other numbers
>which are not defined symbolically. I really don't feel like hard-coding
>numbers in my programs.
>
>Now when Windows becomes Windows NT, then it probably needs to be
>redefined for the new file system, but it can *still* be done with
>a single #defined constant:
> #ifdef WIN_NT
> #define MAX_LENGTH_PATHNAME xx
> #else
> #define MAX_LENGTH_PATHNAME yy
> #endif
>
>So which is it? 80, 144, 255, 260???
>
>--
>John A. Grant jagrant@emr1.emr.ca
>Airborne Geophysics
>Geological Survey of Canada, Ottawa
>
In DOS on a standalone machine, you're allowed 63 characters for the drive
and directory, and another 12 for the filename, plus the NUL byte at the
end. That's a total of 76, hence (presumably) the "80" definition. That
76 is a limitation of MS-DOS itself.
If you're on a network, things get more hairy. On a LAN Manager network,
at least, you're allowed to add a server and sharename to the start of the
path, so you might have something like:
\\app_server\word\myfiles\..... etc
I seem to recall (though I'm probably wrong!) that both server and sharename
can be up to 16 characters long, which, with the separators, brings us
up to 112 characters.
The solution you mention with NT, ie, saying:
#ifdef WIN_NT
etc.
unfortunately doesn't work, either! The trouble is, NT has installable
file systems. You can "plug in" a new file system and neither the NT
Kernel *nor* any of the API subsystems (such as Win32) will know anything
about it, as such. The limit on the length of a filename is a parameter of
the file system currently being accessed, *not* of NT itself!
I think that you've raised an interesting point, though, certainly.
Personally I use a file-name buffer of 256 characters now, just to be on
the safe side.....
Chris
--
--------------------------------------------------------------------------
| Chris Marriott | chris@chrism.demon.co.uk |
| Warrington, UK | BIX: cmarriott |
| (Still awaiting inspiration | CIX: cmarriott |
| for a witty .sig .... ) | CompuServe: 100113,1140 |
--------------------------------------------------------------------------
Technical Details
Message-ID:
<725830790snz@chrism.demon.co.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!pipex!demon!chrism.demon.co.uk!chrisReferences:
<1992Dec31.013722.18655@emr1.emr.ca>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc From: chris@chrism.demon.co.uk (Chris Marriott) Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!demon!chrism.demon.co.uk!chris Subject: Re: buffer sizes for filenames, pathnames etc. Distribution: world References: <1992Dec31.013722.18655@emr1.emr.ca> Organization: None Reply-To: chris@chrism.demon.co.uk X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19) Lines: 71 Date: Thu, 31 Dec 1992 19:39:50 +0000 Message-ID: <725830790snz@chrism.demon.co.uk> Sender: usenet@demon.co.uk