473,382 Members | 1,204 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,382 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 18877
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.