Changeset 2702 for trunk/src/kmk/kmkbuiltin/mscfakes.c
- Timestamp:
- Nov 21, 2013, 1:11:08 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/mscfakes.c
r2645 r2702 109 109 110 110 111 staticint112 msc_set_errno(DWORD dwErr)111 int 112 birdSetErrno(DWORD dwErr) 113 113 { 114 114 switch (dwErr) … … 184 184 DWORD fAttr = GetFileAttributes(pszPath); 185 185 if (fAttr == INVALID_FILE_ATTRIBUTES) 186 rc = msc_set_errno(GetLastError());186 rc = birdSetErrno(GetLastError()); 187 187 else if (fMustBeDir & !(fAttr & FILE_ATTRIBUTE_DIRECTORY)) 188 188 { … … 200 200 fAttr |= FILE_ATTRIBUTE_READONLY; 201 201 if (!SetFileAttributes(pszPath, fAttr)) 202 rc = msc_set_errno(GetLastError());202 rc = birdSetErrno(GetLastError()); 203 203 } 204 204 … … 224 224 DWORD fAttr = GetFileAttributes(pszPath); 225 225 if (fAttr == INVALID_FILE_ATTRIBUTES) 226 rc = msc_set_errno(GetLastError());226 rc = birdSetErrno(GetLastError()); 227 227 else if (fMustBeDir & !(fAttr & FILE_ATTRIBUTE_DIRECTORY)) 228 228 { … … 245 245 fAttr |= FILE_ATTRIBUTE_READONLY; 246 246 if (!SetFileAttributes(pszPath, fAttr)) 247 rc = msc_set_errno(GetLastError());247 rc = birdSetErrno(GetLastError()); 248 248 } 249 249 … … 283 283 if (s_pfnCreateHardLinkA(pszLink, pszDst, NULL)) 284 284 return 0; 285 return msc_set_errno(GetLastError());285 return birdSetErrno(GetLastError()); 286 286 } 287 287 … … 535 535 536 536 537 /*538 * Workaround for directory names with trailing slashes.539 */540 #undef stat541 int542 bird_w32_stat(const char *path, struct stat *st)543 {544 int rc = stat(path, st);545 if ( rc != 0546 && errno == ENOENT547 && *path != '\0')548 {549 char *slash = strchr(path, '\0') - 1;550 if (*slash == '/' || *slash == '\\')551 {552 size_t len_path = slash - path + 1;553 char *tmp = alloca(len_path + 4);554 memcpy(tmp, path, len_path);555 tmp[len_path] = '.';556 tmp[len_path + 1] = '\0';557 errno = 0;558 rc = stat(tmp, st);559 if ( rc == 0560 && !S_ISDIR(st->st_mode))561 {562 errno = ENOTDIR;563 rc = -1;564 }565 }566 }567 #ifdef KMK_PRF568 {569 int err = errno;570 fprintf(stderr, "stat(%s,) -> %d/%d\n", path, rc, errno);571 errno = err;572 }573 #endif574 return rc;575 }576
Note:
See TracChangeset
for help on using the changeset viewer.