Changeset 2702 for trunk/src/kmk/kmkbuiltin
- Timestamp:
- Nov 21, 2013, 1:11:08 AM (12 years ago)
- Location:
- trunk/src/kmk/kmkbuiltin
- Files:
-
- 4 edited
-
cp.c (modified) (1 diff)
-
mscfakes.c (modified) (7 diffs)
-
mscfakes.h (modified) (3 diffs)
-
rm.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/cp.c
r2466 r2702 83 83 84 84 #if defined(_MSC_VER) || defined(__gnu_linux__) || defined(__linux__) 85 extern char *strlcpy(char *, const char *, size_t);85 extern size_t strlcpy(char *, const char *, size_t); 86 86 #endif 87 87 -
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 -
trunk/src/kmk/kmkbuiltin/mscfakes.h
r2592 r2702 39 39 #include <io.h> 40 40 #include <direct.h> 41 #include "nt/ntstat.h" 41 42 #if defined(MSC_DO_64_BIT_IO) && _MSC_VER >= 1400 /* We want 64-bit file lengths here when possible. */ 42 43 # define off_t __int64 43 # undef stat44 # define stat _stat6445 # define fstat _fstat6446 44 # define lseek _lseeki64 47 #else48 # ifndef STAT_REDEFINED_ALREADY49 # define STAT_REDEFINED_ALREADY50 # undef stat51 # define stat(_path, _st) bird_w32_stat(_path, _st)52 extern int bird_w32_stat(const char *, struct stat *);53 # endif54 45 #endif 55 56 #ifndef S_ISDIR57 # define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)58 #endif59 #ifndef S_ISREG60 # define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)61 #endif62 #define S_ISLNK(m) 063 #define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)64 #define S_IXUSR _S_IEXEC65 #define S_IWUSR _S_IWRITE66 #define S_IRUSR _S_IREAD67 #define S_IRWXG 000007068 #define S_IRGRP 000004069 #define S_IWGRP 000002070 #define S_IXGRP 000001071 #define S_IRWXO 000000772 #define S_IROTH 000000473 #define S_IWOTH 000000274 #define S_IXOTH 000000175 #define S_ISUID 000400076 #define S_ISGID 000200077 #define ALLPERMS 000077778 46 79 47 #undef PATH_MAX … … 141 109 #define geteuid() 0 142 110 #define getegid() 0 143 #define lstat(path, s) stat(path, s)144 111 int lchmod(const char *path, mode_t mode); 145 112 int msc_chmod(const char *path, mode_t mode); … … 172 139 int writev(int fd, const struct iovec *vector, int count); 173 140 141 142 143 /* 144 * MSC fake internals / helpers. 145 */ 146 int birdSetErrno(unsigned dwErr); 147 174 148 #endif /* _MSC_VER */ 175 149 #endif -
trunk/src/kmk/kmkbuiltin/rm.c
r2546 r2702 499 499 rval = undelete(f); 500 500 operation = "undelete"; 501 #ifndef _MSC_VER 501 502 } else if (S_ISDIR(sb.st_mode)) { 503 #else 504 } else if (S_ISDIR(sb.st_mode) || sb.st_dirsymlink) { 505 #endif 502 506 rval = rmdir(f); 503 507 operation = "rmdir";
Note:
See TracChangeset
for help on using the changeset viewer.
