Lines Matching refs:path

157 	int		postsiz;	/* state.path post index	*/
158 int presiz; /* state.path pre index */
172 int pathsiz; /* state.path buffer size */
175 char* path; /* to pathname buffer */
191 preserve(State_t* state, const char* path, struct stat* ns, struct stat* os)
195 if (tmxtouch(path, tmxgetatime(os), tmxgetmtime(os), TMX_NOTIME, 0))
196 error(ERROR_SYSTEM|2, "%s: cannot reset access and modify times", path);
198 if (n && chown(state->path, os->st_uid, os->st_gid))
202 error(ERROR_SYSTEM|2, "%s: cannot reset group to %s", path, fmtgid(os->st_gid));
205 error(ERROR_SYSTEM|2, "%s: cannot reset owner to %s", path, fmtuid(os->st_uid));
208 error(ERROR_SYSTEM|2, "%s: cannot reset owner to %s and group to %s", path, fmtuid(os->st_uid), fmtgid(os->st_gid));
276 if ((state->postsiz + len) > state->pathsiz && !(state->path = newof(state->path, char, state->pathsiz = roundof(state->postsiz + len, PATH_CHUNK), 0)))
280 s = state->path + state->postsiz;
285 if (access(state->path, F_OK))
291 stat(state->path, &st);
294 if (mkdir(state->path, st.st_mode & S_IPERM))
296 error(ERROR_SYSTEM|2, "%s: cannot create directory -- %s ignored", state->path, ent->fts_path);
312 memcpy(state->path + state->postsiz, base, len);
314 state->path[state->postsiz] = 0;
315 if (stat(state->path, &st))
316 error(ERROR_SYSTEM|2, "%s: cannot stat", state->path);
319 if ((ent->fts_statp->st_mode & S_IPERM) != (st.st_mode & S_IPERM) && chmod(state->path, ent->fts_statp->st_mode & S_IPERM))
320 error(ERROR_SYSTEM|2, "%s: cannot reset directory mode to %s", state->path, fmtmode(st.st_mode & S_IPERM, 0) + 1);
322 preserve(state, state->path, &st, ent->fts_statp);
352 memcpy(state->path + state->postsiz, base, len);
353 if (!(*state->stat)(state->path, &st))
357 error(2, "%s: not a directory -- %s ignored", state->path, ent->fts_path);
361 else if (mkdir(state->path, (ent->fts_statp->st_mode & S_IPERM)|(ent->fts_info == FTS_D ? S_IRWXU : 0)))
363 error(ERROR_SYSTEM|2, "%s: cannot create directory -- %s ignored", state->path, ent->fts_path);
369 state->path[state->postsiz++] = '/';
395 memcpy(state->path + state->postsiz, base, len);
396 if ((*state->stat)(state->path, &st))
418 sfputr(sfstdout, state->path, '\n');
422 error(2, "%s: identical to %s", state->path, ent->fts_path);
427 error(2, "%s: cannot %s existing directory", state->path, state->opname);
431 sfputr(sfstdout, state->path, '\n');
435 if ((n = open(state->path, O_RDWR|O_BINARY)) >= 0)
442 if (astquery(-1, "%s %s? ", state->opname, state->path) < 0 || sh_checksig(state->context))
447 error(2, "%s: cannot %s existing file", state->path, state->opname);
463 if (astquery(-1, "override protection %s for %s? ", protection, state->path) < 0 || sh_checksig(state->context))
469 error(2, "%s: cannot %s %s protection", state->path, state->opname, protection);
479 if (s = strrchr(state->path, '/'))
481 e = state->path;
487 s = state->path;
501 if (s != state->path)
505 sfprintf(state->tmp, "%s.%s%d%s", state->path, state->suffix, v + 1, state->suffix);
510 sfprintf(state->tmp, "%s%s", state->path, state->suffix);
513 error(ERROR_SYSTEM|3, "%s: out of space", state->path);
514 if (rename(state->path, s))
516 error(ERROR_SYSTEM|2, "%s: cannot backup to %s", state->path, s);
521 if (rm && remove(state->path))
523 error(ERROR_SYSTEM|2, "%s: cannot remove", state->path);
535 if (!rename(ent->fts_path, state->path))
539 else if (!rm && st.st_mode && !remove(state->path))
546 error(ERROR_SYSTEM|2, "%s: cannot rename to %s", ent->fts_path, state->path);
562 if (pathsetlink(state->text, state->path))
564 error(ERROR_SYSTEM|2, "%s: cannot copy symbolic link to %s", ent->fts_path, state->path);
575 else if ((wfd = open(state->path, st.st_mode ? (state->wflags & ~O_EXCL) : state->wflags, ent->fts_statp->st_mode & state->perm)) < 0)
577 error(ERROR_SYSTEM|2, "%s: cannot write", state->path);
586 error(ERROR_SYSTEM|2, "%s: %s read stream error", ent->fts_path, state->path);
595 error(ERROR_SYSTEM|2, "%s: %s write stream error", ent->fts_path, state->path);
610 error(ERROR_SYSTEM|2, "%s: %s %s error", ent->fts_path, state->path, n == 1 ? ERROR_translate(0, 0, 0, "read") : n == 2 ? ERROR_translate(0, 0, 0, "write") : ERROR_translate(0, 0, 0, "io"));
619 if (mknod(state->path, ent->fts_statp->st_mode, idevice(ent->fts_statp)))
621 error(ERROR_SYSTEM|2, "%s: cannot copy special file to %s", ent->fts_path, state->path);
634 if (stat(state->path, &st))
635 error(ERROR_SYSTEM|2, "%s: cannot stat", state->path);
638 if ((ent->fts_statp->st_mode & state->perm) != (st.st_mode & state->perm) && chmod(state->path, ent->fts_statp->st_mode & state->perm))
639 error(ERROR_SYSTEM|2, "%s: cannot reset mode to %s", state->path, fmtmode(st.st_mode & state->perm, 0) + 1);
640 preserve(state, state->path, &st, ent->fts_statp);
648 if ((*state->link)(ent->fts_path, state->path))
649 error(ERROR_SYSTEM|2, "%s: cannot link to %s", ent->fts_path, state->path);
725 error(ERROR_SYSTEM|3, "%s: out of space", state->path);
909 if (state->pathsiz < roundof(state->postsiz + 2, PATH_CHUNK) && !(state->path = newof(state->path, char, state->pathsiz = roundof(state->postsiz + 2, PATH_CHUNK), 0)))
911 memcpy(state->path, file, state->postsiz + 1);
912 if (state->directory && state->path[state->postsiz - 1] != '/')
913 state->path[state->postsiz++] = '/';
941 else if ((*state->link)(*argv, state->path))
942 error(ERROR_SYSTEM|2, "%s: cannot link to %s", *argv, state->path);
945 if (state->path)
946 free(state->path);