473,408 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

PATH_MAX

Greetings.

I was under the impression that PATH_MAX (i.e., the maximum length, in
characters, of a fully-qualified filename) was part of standard C and
defined in <limits.h>, but apparently I am wrong. (At least, I can't
find it in the C9X draft, and a trivial program using it won't compile
with gcc -ansi.)

Any suggestions for what to replace it with? Is there some relatively
safe arbitrary numerical constant I could use? I.e., what's the
greatest value I'm likely to encounter on today's popular platforms?
I'd hate to pick some value, x, thinking it's "big enough", and then
have some user complain when she tries to input a filename of length
x+1.

The program is aimed at logicians, mathematicians, and computer
scientists, so I expect most of them will be running Windows, DOS,
MacOS, or some variant of Unix (including GNU, Linux, BSD, OS X, etc.).
No need to worry about accommodating obscure embedded systems and
what-not.

Regards,
Tristan

--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\ http://www.nothingisreal.com/ >< To finish what you
Nov 14 '05 #1
4 18881
Tristan Miller wrote:
I was under the impression that PATH_MAX (i.e., the maximum length, in
characters, of a fully-qualified filename) was part of standard C and
defined in <limits.h>, but apparently I am wrong. (At least, I can't
find it in the C9X draft, and a trivial program using it won't compile
with gcc -ansi.)

Any suggestions for what to replace it with?


FILENAME_MAX is available to standard C programs. It "expands to an
integer constant expression that is the size needed for an array of
char large enough to hold the longest file name string that the
implementation guarantees can be opened". Note, though, that this is
quite different from the "maximum length [...] of a fully-qualified
filename". Also, some systems have no such maximum, or at least a
maximum that is larger than any array you'd want to allocate. It's
usually better to dynamically allocate the buffer where possible (and
thus handle arrays of arbitrary size).

Jeremy.

Nov 14 '05 #2
Tristan Miller wrote:
I was under the impression that PATH_MAX (i.e., the maximum length, in
characters, of a fully-qualified filename) was part of standard C and
defined in <limits.h>, but apparently I am wrong. (At least, I can't
find it in the C9X draft, and a trivial program using it won't compile
with gcc -ansi.)

Any suggestions for what to replace it with?


FILENAME_MAX is available to standard C programs. It "expands to an
integer constant expression that is the size needed for an array of
char large enough to hold the longest file name string that the
implementation guarantees can be opened". Note, though, that this is
quite different from the "maximum length [...] of a fully-qualified
filename". Also, some systems have no such maximum, or at least a
maximum that is larger than any array you'd want to allocate. It's
usually better to dynamically allocate the buffer where possible (and
thus handle filenames of arbitrary length).

Jeremy.

Nov 14 '05 #3
Greetings.

In article <sl*******************@hehe.cl.cam.ac.uk>, Jeremy Yallop
wrote:
Tristan Miller wrote:
I was under the impression that PATH_MAX (i.e., the maximum length,
in characters, of a fully-qualified filename) was part of standard C
and
defined in <limits.h>, but apparently I am wrong. (At least, I can't
find it in the C9X draft, and a trivial program using it won't
compile with gcc -ansi.)

Any suggestions for what to replace it with?


FILENAME_MAX is available to standard C programs.


Ah, thank you. Is this in C89 or only in C99?

Regards,
Tristan

--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\ http://www.nothingisreal.com/ >< To finish what you
Nov 14 '05 #4
In <73****************@ID-187157.news.dfncis.de> Tristan Miller <ps********@nothingisreal.com> writes:
Greetings.

In article <sl*******************@hehe.cl.cam.ac.uk>, Jeremy Yallop
wrote:

FILENAME_MAX is available to standard C programs.


Ah, thank you. Is this in C89 or only in C99?


It's C89, so you can safely rely on its availability.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joseph | last post by:
Hi all, I am writting a program which loops each sub-dir inside the /proc and output the "exe" symbolic link using readlink() ,but I have a problem with the output .I think it's the problem of...
34
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS:...
13
by: Ioannis Vranos | last post by:
Hi all, Is long long supposed to be supported in all C99 implementations?If yes is it supposed to be 64 bit at least? GCC says that it supports long long, but i got this: #include <stdio.h>...
11
by: Thomas Zangl | last post by:
Hi! I have a class hierachie like this: // interface, abstract only class ISession { } // implements common parts of ISession
1
by: mariodr | last post by:
Hi! This is my first post on the web ever! To make it short, I made a routine to change certain bytes in a file in binary mode. It all worked perfectly, until I decided to use a long name...
7
by: dasarath mood | last post by:
char id_dir = {0,}; strncpy(id_dir, a->id_file_name, PATH_MAX); id_dir = 0; strncpy(id_dir, ".d/", PATH_MAX - strnlen(id_dir, PATH_MAX)); struct dirent *id_file = NULL; do { errno = 0; ...
6
by: tgnelson85 | last post by:
Hello, C question here (running on Linux, though there should be no platform specific code). After reading through a few examples, and following one in a book, for linked lists i thought i would...
5
by: mike.rosset+gnus | last post by:
Hello All: I am new to C and I have a program design question. Not only am I trying to learn C but I'm also trying to pick up good habits. And I'm cocerned with doing things the right and...
2
by: Eric Sosman | last post by:
Eric Sosman wrote: Never mind; I see now what I overlooked on first reading: Still, it might be better to return a pointer to a dynamically- allocated region whose size is *known* to be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.