Mercurial > vim
comparison src/os_win32.c @ 6345:9bc6ce142cc3 v7.4.505
updated for version 7.4.505
Problem: On MS-Windows when 'encoding' is a double-byte encoding a file
name longer than MAX_PATH bytes but shorter than that in
characters causes problems.
Solution: Fail on file names longer than MAX_PATH bytes. (Ken Takata)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 05 Nov 2014 18:36:03 +0100 |
parents | e3149e2b4152 |
children | 9f9058aeba0d |
comparison
equal
deleted
inserted
replaced
6344:8a860e8b02e1 | 6345:9bc6ce142cc3 |
---|---|
6137 * the _wopen() fails for missing wide functions. */ | 6137 * the _wopen() fails for missing wide functions. */ |
6138 } | 6138 } |
6139 } | 6139 } |
6140 # endif | 6140 # endif |
6141 | 6141 |
6142 /* open() can open a file which name is longer than _MAX_PATH bytes | |
6143 * and shorter than _MAX_PATH characters successfully, but sometimes it | |
6144 * causes unexpected error in another part. We make it an error explicitly | |
6145 * here. */ | |
6146 if (strlen(name) >= _MAX_PATH) | |
6147 return -1; | |
6148 | |
6142 return open(name, flags, mode); | 6149 return open(name, flags, mode); |
6143 } | 6150 } |
6144 | 6151 |
6145 /* | 6152 /* |
6146 * Version of fopen() that may use UTF-16 file name. | 6153 * Version of fopen() that may use UTF-16 file name. |
6185 return f; | 6192 return f; |
6186 /* Retry with non-wide function (for Windows 98). Can't use | 6193 /* Retry with non-wide function (for Windows 98). Can't use |
6187 * GetLastError() here and it's unclear what errno gets set to if | 6194 * GetLastError() here and it's unclear what errno gets set to if |
6188 * the _wfopen() fails for missing wide functions. */ | 6195 * the _wfopen() fails for missing wide functions. */ |
6189 } | 6196 } |
6197 | |
6198 /* fopen() can open a file which name is longer than _MAX_PATH bytes | |
6199 * and shorter than _MAX_PATH characters successfully, but sometimes it | |
6200 * causes unexpected error in another part. We make it an error explicitly | |
6201 * here. */ | |
6202 if (strlen(name) >= _MAX_PATH) | |
6203 return NULL; | |
6190 | 6204 |
6191 return fopen(name, mode); | 6205 return fopen(name, mode); |
6192 } | 6206 } |
6193 #endif | 6207 #endif |
6194 | 6208 |