From b058361b1cc851760824f6cac5b3900950b33638 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 7 Sep 2021 13:07:47 +0800 Subject: [PATCH] added a few comment that they are talk about filename length limited. --- inc/hgl/filesystem/FileSystem.h | 15 ++++++++++++++- inc/hgl/platform/os/MSWindows.h | 7 ++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/inc/hgl/filesystem/FileSystem.h b/inc/hgl/filesystem/FileSystem.h index 3c4d376..9d5cc35 100644 --- a/inc/hgl/filesystem/FileSystem.h +++ b/inc/hgl/filesystem/FileSystem.h @@ -46,7 +46,20 @@ namespace hgl bool GetCurrentProgramPath(OSString &); ///<取得当前程序所在路径 bool GetLocalAppdataPath(OSString &); ///<取得当前用户应用程序数据存放路径 - //使用int64而不是__int64是因为不是所有编译器都支持__int64的写法,必须使用DataType.H中引入的定义 + /** + * 文件名长度限制 + * + * OS | FILENAME | FILENAME+PATHNAME | + * ------------------+----------+-------------------+ + * Windows 256 260 + * Windows 10(>1607) 32767 32767 // max length must get from lpMaximumComponentLength of GetVolumeInformation + * // https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell + * + * MacOS/Solaris/AIX 255 1024 + * Linux 255 1024/4096 + */ + + //使用int64而不是__int64是因为不是所有编译器都支持__int64的写法,必须使用DataType.h中引入的定义 /** * 文件信息数据结构 diff --git a/inc/hgl/platform/os/MSWindows.h b/inc/hgl/platform/os/MSWindows.h index 7a00577..befbc04 100644 --- a/inc/hgl/platform/os/MSWindows.h +++ b/inc/hgl/platform/os/MSWindows.h @@ -46,7 +46,12 @@ using os_char =wchar_t; #define HGL_LINE_END OS_TEXT("\r\n") //换行符 #define HGL_LINE_END_SIZE 2 //换行符长度 -#define HGL_MAX_PATH MAX_PATH +/** +* 从Windows 10(ver 1607)开始,NTFS分区文件名最大长度为32767。 +* 但由于文件系统的不同,我们需要使用 GetVolumeInformation 函数,根据参数lpMaximumComponentLength的返回值来确定每个分区可使用的最大长度 +*/ + +#define HGL_MAX_PATH MAX_PATH //文件名最大长度 #define HGL_MEM_ALIGN 16 //内存对齐字节数 //--------------------------------------------------------------------------------------------------