- Timestamp:
- Oct 23, 2007 12:46:50 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/nt_fullpath.c
r1175 r1248 151 151 char *pszEnd; 152 152 int iLongNameDiff; 153 size_t cch; 153 154 154 155 … … 157 158 while (*pszEnd && *pszEnd != '/' && *pszEnd != '\\') 158 159 pszEnd++; 160 cch = pszEnd - psz; 159 161 160 162 /* replace the end with "?\0" */ … … 171 173 cchLast = psz - pszPath; 172 174 memcpy(s_szLast, pszPath, cchLast + 1); 175 s_szLast[cchLast + 1] = '\0'; 173 176 pszEnd[0] = chSaved0; 174 177 return; … … 182 185 cchLast = psz - pszPath; 183 186 memcpy(s_szLast, pszPath, cchLast + 1); 187 s_szLast[cchLast + 1] = '\0'; 184 188 pszEnd[0] = chSaved0; 185 189 return; 186 190 } 187 191 } 188 strcpy(psz, !iLongNameDiff ? FindFileData.cFileName : FindFileData.cAlternateFileName);189 192 pszEnd[0] = chSaved0; 193 if ( iLongNameDiff /* matched the short name */ 194 || !FindFileData.cAlternateFileName[0] /* no short name */ 195 || !memchr(psz, ' ', cch)) /* no spaces in the matching name */ 196 memcpy(psz, !iLongNameDiff ? FindFileData.cFileName : FindFileData.cAlternateFileName, cch); 197 else 198 { 199 /* replace spacy name with the short name. */ 200 const size_t cchAlt = strlen(FindFileData.cAlternateFileName); 201 const size_t cchDelta = cch - cchAlt; 202 my_assert(cchAlt > 0); 203 if (!cchDelta) 204 memcpy(psz, FindFileData.cAlternateFileName, cch); 205 else 206 { 207 size_t cbLeft = strlen(pszEnd) + 1; 208 if ((psz - pszPath) + cbLeft + cchAlt <= _MAX_PATH) 209 { 210 memmove(psz + cchAlt, pszEnd, cbLeft); 211 pszEnd -= cchDelta; 212 memcpy(psz, FindFileData.cAlternateFileName, cchAlt); 213 } 214 else 215 fprintf(stderr, "kBuild: case & space fixed filename is growing too long (%d bytes)! '%s'\n", 216 (psz - pszPath) + cbLeft + cchAlt, pszPath); 217 } 218 } 219 my_assert(pszEnd[0] == chSaved0); 190 220 FindClose(hDir); 191 221 … … 386 416 /* 387 417 * The simple case, the file / dir / whatever exists and can be 388 * queried without problems .418 * queried without problems and spaces. 389 419 */ 390 420 if (nt_get_filename_info(pszPath, pszFull, cchFull) == 0) 391 421 { 422 /** @todo make nt_get_filename_info return spaceless path. */ 423 if (strchr(pszPath, ' ')) 424 w32_fixcase(pszPath); 392 425 #if 0 393 426 fprintf(stderr, "nt #%d - %s\n", ++s_cHits, pszFull);
Note:
See TracChangeset
for help on using the changeset viewer.