• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Max Limit on characters in file name to use renameTo( ) in linux or windows?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,
I am trying to rename a file of 200 characters in the filename.
unfortunately the rename doesn't work.
Is there any maximum limit on the characters present in the filename to use the renameTo( ) command in linux or windows?

Thanks,
Shanker.

[ October 14, 2005: Message edited by: Sai Shanker ]
[ October 14, 2005: Message edited by: Sai Shanker ]
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java is not C, but C has the answer in this case, at least on Linux/UNIX.

 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's the maximum path length supported by the C library. The filename length supported by the OS or by the underlying filesystem is something else altogether.
 
Harald Kirsch
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed.

http://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits

Recently no day passes where Wikipedia does not surprise me
 
Sai Shanker
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Harald and Ernest,
Thank you so much for sharing the information. What i figured out today is on XP upto 170 characters in the file name works fine above that it creates problems.I didn't yet work with linux.

Shanker
[ October 14, 2005: Message edited by: Sai Shanker ]
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In most of linux distributions the maximum path length can go upto 4096 charaacters while the max length of the file name is 255 characters.

For finding what is the max filename supports check "man 2 statfs".

Please find a small code snippet in C to find this out.

***************************************************
#include <sys/vfs.h>
/* or include <sys/statfs.h>*/

int void main(int argc, char* argv[])
struct statfs buf;
char * filename="/home/bhopal/abc"
if ( statfs(filename, &buf) == 0 )
{
printf("\n The max file name suppoted = %ld",buf.f_namelen);

}else{
printf("\n Error during statfs");
}
}
***************************************************

I hope it helps!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic