在linux上,文件夹和文件名的长度有限制。 以ubuntu为例,描述文件路径为/usr/include/linux/limits.h
#ifndef _LINUX_LIMITS_H
#define _LINUX_LIMITS_H
#define NR_OPEN 1024
# definen groups _ max 65536/* supplementalgroupidsareavailable * /
# define arg _ max 131072/* # bytesofargsenvironforexec (* /
# define link _ max 127/* # linksafilemayhave * /
# definemax _ canon 255/* sizeofthecanonicalinputqueue * /
# definemax _ input 255/* sizeof the type-ahead buffer * /
# definename _ max 255/* # charsinafilename * /
# define path _ max 4096/* # charsinapathnameincludingnul * /
# define pipe _ buf 4096/* # bytesinatomicwritetoapipe * /
# define xattr _ name _ max 255/* # charsinanextendedattributename * /
# define xattr _ size _ max 65536/* sizeofanextendedattributevalue (64k ) /
# define xattr _ list _ max 65536/* sizeofextendedattributenamelist (64k ) /
#define RTSIG_MAX 32
#endif
据说android在文件名和路径上也有同样的限制,因为文件名太长,扫描可能会直接崩溃。