Changeset 727 in kBuild for trunk/src/lib/kDep.c
- Timestamp:
- Dec 17, 2006 1:43:01 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/kDep.c
r407 r727 84 84 #ifdef __WIN32__ 85 85 /** 86 * Corrects the case of a path. 87 * Expects a fullpath! 86 * Corrects the case of a path and changes any path components containing 87 * spaces with the short name (which can be longer). 88 * 89 * Expects a _fullpath! 88 90 * 89 91 * @param pszPath Pointer to the path, both input and output. 90 * The buffer must be a ble to hold one more byte than the stringlength.92 * The buffer must be at least MAX_PATH in length. 91 93 */ 92 94 static void fixcase(char *pszPath) … … 158 160 char chSaved1; 159 161 char *pszEnd; 162 int cch; 163 int iLongNameDiff; 160 164 161 165 … … 164 168 while (*pszEnd && *pszEnd != '/' && *pszEnd != '\\') 165 169 pszEnd++; 170 cch = pszEnd - psz; 166 171 167 172 /* replace the end with "?\0" */ … … 180 185 } 181 186 pszEnd[0] = '\0'; 182 while (stricmp(FindFileData.cFileName, psz)) 187 while ( (iLongNameDiff = stricmp(FindFileData.cFileName, psz)) 188 && stricmp(FindFileData.cAlternateFileName, psz)) 183 189 { 184 190 if (!FindNextFile(hDir, &FindFileData)) … … 188 194 } 189 195 } 190 strcpy(psz, FindFileData.cFileName);191 196 pszEnd[0] = chSaved0; 197 if (iLongNameDiff || !FindFileData.cAlternateFileName[0] || !memchr(psz, ' ', cch)) 198 memcpy(psz, !iLongNameDiff ? FindFileData.cFileName : FindFileData.cAlternateFileName, cch); 199 else 200 { 201 /* replace spacy name with the short name. */ 202 const int cchAlt = strlen(FindFileData.cAlternateFileName); 203 const int cchDelta = cch - cchAlt; 204 my_assert(cchAlt > 0); 205 if (!cchDelta) 206 memcpy(psz, FindFileData.cAlternateFileName, cch); 207 else 208 { 209 memmove(psz + cchAlt, pszEnd, strlen(pszEnd) + 1); 210 pszEnd -= cchDelta; 211 memcpy(psz, FindFileData.cAlternateFileName, cchAlt); 212 } 213 } 214 my_assert(pszEnd[0] == chSaved0); 192 215 193 216 /* advance to the next component */
Note:
See TracChangeset
for help on using the changeset viewer.