• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Sai Shanker
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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 ]
 
Harald Kirsch
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is not C, but C has the answer in this case, at least on Linux/UNIX.

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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 ]
 
Bhopal Singh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!