Lines Matching full:path
38 * tidypath removes excess slashes and "." references from a path string
78 static int tidy_path (char *path)
83 s = path + strlen(path) - 1;
88 while (substr(path, "/./", "/"))
90 while (substr(path, "//", "/"))
93 while ((p = strstr(path,"/../")) != NULL) {
95 for (p--; p != path; p--) if (*p == '/') break;
101 if (*path == '\0')
102 strcpy(path,"/");
103 p = path + strlen(path) - 1;
104 if (p != path && *p == '/')
106 while (p != path && *p == '/') { /* remove any others */
110 while (!strncmp(path,"./",2)) {
111 for (p = path, s = path+2; (*p++ = *s++););
117 static int shorten_path (char *path, char *abspath)
124 while (abspath && strlen(abspath) > 1 && (p = strstr(path,"../"))) {
162 static void fix_symlink (char *path, dev_t my_dev)
169 if ((c = readlink(path, lpath, sizeof(lpath))) == -1) {
170 perror(path);
178 strcat(abspath,path);
191 printf("dangling: %s -> %s\n", path, lpath);
193 if (unlink (path)) {
194 perror(path);
196 printf("deleted: %s -> %s\n", path, lpath);
215 fix_long = shorten_path(new, path);
223 printf("%s %s -> %s\n", msg, path, lpath);
229 /* point tail at first part of lpath that differs from path */
230 /* point p at first part of path that differs from lpath */
233 p = path;
253 if (shorten) (void) shorten_path(new, path);
255 shorten_path(new,path);
257 if (unlink (path)) {
258 perror(path);
261 if (symlink(new, path)) {
262 perror(path);
266 printf("changed: %s -> %s\n", path, new);
269 static void dirwalk (char *path, int pathlen, dev_t dev)
276 if ((dfd = opendir(path)) == NULL) {
277 perror(path);
281 name = path + pathlen;
288 if (lstat(path, &st) == -1) {
289 perror(path);
292 fix_symlink (path, dev);
294 dirwalk(path, strlen(path), dev);
300 path[pathlen] = '\0';
321 static char path[PATH_MAX+2];
324 static char path[PATH_MAX+2], cwd[PATH_MAX+2];
371 *path = '\0';
373 strcpy(path,cwd);
374 tidy_path(strcat(path, p));
375 if (lstat(path, &st) == -1)
376 perror(path);
378 fix_symlink(path, st.st_dev);
380 dirwalk(path, strlen(path), st.st_dev);