Lines Matching refs:path

89 suffix(register const char* path)
91 register const char* s = path + strlen(path);
94 while (s > path)
103 execrate(const char* path, char* buf, int size, int physical)
109 if (suffix(path))
112 if (physical || strlen(path) >= size || !(s = pathcanon(strcpy(buf, path), PATH_PHYSICAL|PATH_DOTDOT|PATH_EXISTS)))
113 snprintf(buf, size, "%s.exe", path);
121 * return 0 if path is magic, -1 otherwise
122 * ux!=0 set to 1 if path is unix executable
127 magic(const char* path, int* ux)
141 if ((fd = _open(path, O_RDONLY, 0)) >= 0)
180 access(const char* path, int op)
187 if ((r = _access(path, op)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
222 chmod(const char* path, mode_t mode)
228 if ((r = _chmod(path, mode)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
233 if (!(r = _chmod(path, mode)) &&
235 !suffix(path) &&
236 (strlen(path) + 4) < sizeof(buf))
239 if (!magic(path, NiL))
241 snprintf(buf, sizeof(buf), "%s.exe", path);
242 _rename(path, buf);
351 runve(int mode, const char* path, char* const* argv, char* const* envv)
402 if (execrate(path, buf, sizeof(buf), 0))
405 path = (const char*)buf;
409 if (path != (const char*)buf && _stat(path, &st))
416 if (magic(path, &ux))
432 *p++ = (char*)path;
433 *p++ = (char*)path;
434 path = (const char*)pathshell();
444 * (1) the directory of path
451 * the standard allows PATH to be anything once the path
510 sfprintf(sfstderr, "%s %s [", mode == _P_OVERLAY ? "_execve" : "_spawnve", path);
526 pid = _spawnve(mode, path, argv, envv);
539 pid = _execve(path, argv, envv);
551 execve(const char* path, char* const* argv, char* const* envv)
553 return runve(_P_OVERLAY, path, argv, envv);
561 spawnve(int mode, const char* path, char* const* argv, char* const* envv)
563 return runve(mode, path, argv, envv);
616 char path[PATH_MAX];
638 if (!stat(exe[fd]->path, &st) && st.st_ino == exe[fd]->ino)
640 snprintf(buf, sizeof(buf), "%s.exe", exe[fd]->path);
641 _rename(exe[fd]->path, buf);
661 open(const char* path, int flags, ...)
675 fd = _open(path, flags, mode);
677 if (fd < 0 && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
684 if (fd >= 0 && fd < elementsof(exe) && strlen(path) < PATH_MAX &&
687 if (!suffix(path) && !fstat(fd, &st) && (exe[fd] || (exe[fd] = (Exe_test_t*)malloc(sizeof(Exe_test_t)))))
691 strcpy(exe[fd]->path, path);
705 pathconf(const char* path, int op)
707 if (_access(path, F_OK))
709 return _pathconf(path, op);
740 stat(const char* path, struct stat* st)
747 if ((r = _stat(path, st)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
760 truncate(const char* path, off_t offset)
767 if ((r = _truncate(path, offset)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
780 unlink(const char* path)
808 if (lstat(path, &st) || !S_ISREG(st.st_mode))
810 cygwin_conv_to_full_win32_path(path, nat);
814 path = (const char*)nat;
817 hp = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_DELETE_ON_CLOSE, NULL);
826 if (path == (const char*)buf || !execrate(path, buf, sizeof(buf), 1))
831 path = (const char*)buf;
834 if (_access(path, 0))
837 if (errno != ENOENT || !execrate(path, buf, sizeof(buf), 1) || _access(buf, 0))
839 path = (const char*)buf;
848 * rename to a `deleted' path just in case the file is open
855 if (!_rename(path, tmp))
857 path = (const char*)tmp;
880 if (!errno && !_rename(path, tmp))
882 path = (const char*)tmp;
889 if (execrate(path, buf, sizeof(buf), 1) && !_rename(buf, tmp))
890 path = (const char*)tmp;
899 if (!_rename(path, tmp))
901 path = (const char*)tmp;
909 hp = CreateFile(path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_DELETE_ON_CLOSE, NULL);
919 return _unlink(path);
934 ctime_now(const char* path)
944 if (_stat(path, &fs) || (fs.st_mode & S_IWUSR) || _chmod(path, (fs.st_mode | S_IWUSR) & S_IPERM))
946 cygwin_conv_to_win32_path(path, tmp);
956 _chmod(path, fs.st_mode & S_IPERM);
967 utimes(const char* path, const struct timeval* ut)
974 if ((r = _utimes(path, ut)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
977 r = _utimes(path = buf, ut);
980 ctime_now(path);
985 utime(const char* path, const struct utimbuf* ut)
992 if ((r = _utime(path, ut)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
995 r = _utime(path = buf, ut);
998 ctime_now(path);