Max Path [Newbie]

R

Rookie

I was just wondering whether there is any MAX_PATH macro in C\C++? If not
what is a safe value to assume for maximum path length?
 
D

David Hilsee

Rookie said:
I was just wondering whether there is any MAX_PATH macro in C\C++? If not
what is a safe value to assume for maximum path length?

If you're asking about a constant that defines the largest value that some
file's path may have on the filesystem, then you should ask this question on
a newsgroup that discusses your platform. AFAIK, there is no macro named
MAX_PATH in standard C or C++. If you're on Windows, then Microsoft's MSDN
or Microsoft-specific newsgroups may be useful.
 
J

Jack Klein

If you're asking about a constant that defines the largest value that some
file's path may have on the filesystem, then you should ask this question on
a newsgroup that discusses your platform. AFAIK, there is no macro named
MAX_PATH in standard C or C++. If you're on Windows, then Microsoft's MSDN
or Microsoft-specific newsgroups may be useful.

Nonsense, there is a perfectly valid solution, defined by standard C
and inherited by standard C++.

Look up the macro FILENAME_MAX defined in <stdio.h> and <cstdio>.
 
D

David Hilsee

Jack Klein said:
Nonsense, there is a perfectly valid solution, defined by standard C
and inherited by standard C++.

Look up the macro FILENAME_MAX defined in <stdio.h> and <cstdio>.

I assumed that the original question was about a macro named MAX_PATH and
inferred that Rookie was asking about Windows. My apologies if I assumed
incorrectly. According to MSDN, on Windows, MAX_PATH is 260 characters, and
so is FILENAME_MAX. Rookie would have to provide more information to know
if what he is doing is platform-specific.
 
R

Rookie

I am working on a UNIX platform. I had a vague idea of some MAX_PATH (or
MAXPATH) macro in Windows. But I justed wanted to know how I would do it in
UNIX. But I guess the FILENAME_MAX macro is platform independent and works
well enough. Anyways thanks to both of you guys for your replies!
 
T

Timothy Madden

Jack Klein said:
Nonsense, there is a perfectly valid solution, defined by standard C
and inherited by standard C++.

Look up the macro FILENAME_MAX defined in <stdio.h> and <cstdio>.
This is a real-world problem if you ask me
I don't think FILENAME_MAX would be the same as PATH_MAX.
Take Windows for example: if a filename can be 255 chars, Then a path name
can be many thousands chars.
I think we have a real problem of no standard way to determine the legal
maximum file path length. However this is file-system dependent and I think
a good file-system may well say: I file's path can be any length !

Timothy Madden
Romania
 
J

Jeff Flinn

Rookie said:
I am working on a UNIX platform. I had a vague idea of some MAX_PATH (or
MAXPATH) macro in Windows. But I justed wanted to know how I would do it in
UNIX. But I guess the FILENAME_MAX macro is platform independent and works
well enough. Anyways thanks to both of you guys for your replies!

Size shouldn't matter. :) Avoid the issue altogether by using
boost::filesystem at www.boost.org.

Jeff F
 
A

Alf P. Steinbach

* Jack Klein:
Nonsense, there is a perfectly valid solution, defined by standard C
and inherited by standard C++.

Look up the macro FILENAME_MAX defined in <stdio.h> and <cstdio>.

One should perhaps add that using that constant will not necessarily
allow access to all files and directories on the given system.

For example, the maximum path length for a Unicode path in Windows is
about 32.000 characters (I suspect the actual value is close to 2^15, but
the documentation is vague, as always), whereas FILENAME_MAX might give
a value in the low three-digit range.

Don't know whether boost::filesystem handles that sort of thing, and if so,
how.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top