003 File Manager
Current Path:
/usr/src/contrib/nvi/ex
usr
/
src
/
contrib
/
nvi
/
ex
/
📁
..
📄
ex.awk
(115 B)
📄
ex.c
(61.91 KB)
📄
ex.h
(8.63 KB)
📄
ex_abbrev.c
(2.63 KB)
📄
ex_append.c
(7.05 KB)
📄
ex_args.c
(7.03 KB)
📄
ex_argv.c
(20.06 KB)
📄
ex_at.c
(3.14 KB)
📄
ex_bang.c
(5.25 KB)
📄
ex_cd.c
(2.84 KB)
📄
ex_cmd.c
(11.69 KB)
📄
ex_cscope.c
(24.32 KB)
📄
ex_def.h
(1.4 KB)
📄
ex_delete.c
(1.3 KB)
📄
ex_display.c
(2.71 KB)
📄
ex_edit.c
(3.5 KB)
📄
ex_equal.c
(1.17 KB)
📄
ex_file.c
(1.56 KB)
📄
ex_filter.c
(8.38 KB)
📄
ex_global.c
(7.17 KB)
📄
ex_init.c
(9.93 KB)
📄
ex_join.c
(4.36 KB)
📄
ex_map.c
(3.01 KB)
📄
ex_mark.c
(787 B)
📄
ex_mkexrc.c
(1.96 KB)
📄
ex_move.c
(4.16 KB)
📄
ex_open.c
(867 B)
📄
ex_preserve.c
(1.92 KB)
📄
ex_print.c
(6.43 KB)
📄
ex_put.c
(880 B)
📄
ex_quit.c
(801 B)
📄
ex_read.c
(8 KB)
📄
ex_screen.c
(2.22 KB)
📄
ex_script.c
(12.76 KB)
📄
ex_set.c
(737 B)
📄
ex_shell.c
(4.95 KB)
📄
ex_shift.c
(4.59 KB)
📄
ex_source.c
(2.01 KB)
📄
ex_stop.c
(928 B)
📄
ex_subst.c
(34.22 KB)
📄
ex_tag.c
(28.84 KB)
📄
ex_txt.c
(10.91 KB)
📄
ex_undo.c
(1.33 KB)
📄
ex_usage.c
(4.15 KB)
📄
ex_util.c
(4.18 KB)
📄
ex_version.c
(721 B)
📄
ex_visual.c
(3.68 KB)
📄
ex_write.c
(8 KB)
📄
ex_yank.c
(882 B)
📄
ex_z.c
(3.56 KB)
📄
extern.h
(4.37 KB)
📄
script.h
(588 B)
📄
tag.h
(3.09 KB)
📄
version.h
(40 B)
Editing: ex_cd.c
/*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * Copyright (c) 1992, 1993, 1994, 1995, 1996 * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. */ #include "config.h" #include <sys/queue.h> #include <sys/time.h> #include <bitstring.h> #include <errno.h> #include <limits.h> #include <pwd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "../common/common.h" /* * ex_cd -- :cd[!] [directory] * Change directories. * * PUBLIC: int ex_cd(SCR *, EXCMD *); */ int ex_cd(SCR *sp, EXCMD *cmdp) { struct passwd *pw; ARGS *ap; int savech; char *dir, *p, *t; char *buf; size_t dlen; /* * !!! * Historic practice is that the cd isn't attempted if the file has * been modified, unless its name begins with a leading '/' or the * force flag is set. */ if (F_ISSET(sp->ep, F_MODIFIED) && !FL_ISSET(cmdp->iflags, E_C_FORCE) && sp->frp->name[0] != '/') { msgq(sp, M_ERR, "120|File modified since last complete write; write or use ! to override"); return (1); } switch (cmdp->argc) { case 0: /* If no argument, change to the user's home directory. */ if ((dir = getenv("HOME")) == NULL) { if ((pw = getpwuid(getuid())) == NULL || pw->pw_dir == NULL || pw->pw_dir[0] == '\0') { msgq(sp, M_ERR, "121|Unable to find home directory location"); return (1); } dir = pw->pw_dir; } break; case 1: INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1, dir, dlen); break; default: abort(); } /* * Try the current directory first. If this succeeds, don't display * a message, vi didn't historically, and it should be obvious to the * user where they are. */ if (!chdir(dir)) return (0); /* * If moving to the user's home directory, or, the path begins with * "/", "./" or "../", it's the only place we try. */ if (cmdp->argc == 0 || (ap = cmdp->argv[0])->bp[0] == '/' || (ap->len == 1 && ap->bp[0] == '.') || (ap->len >= 2 && ap->bp[0] == '.' && ap->bp[1] == '.' && (ap->bp[2] == '/' || ap->bp[2] == '\0'))) goto err; /* Try the O_CDPATH option values. */ for (p = t = O_STR(sp, O_CDPATH);; ++p) if (*p == '\0' || *p == ':') { /* * Ignore the empty strings and ".", since we've already * tried the current directory. */ if (t < p && (p - t != 1 || *t != '.')) { savech = *p; *p = '\0'; if ((buf = join(t, dir)) == NULL) { msgq(sp, M_SYSERR, NULL); return (1); } *p = savech; if (!chdir(buf)) { free(buf); if ((buf = getcwd(NULL, 0)) != NULL) { msgq_str(sp, M_INFO, buf, "122|New current directory: %s"); free(buf); } return (0); } free(buf); } t = p + 1; if (*p == '\0') break; } err: msgq_str(sp, M_SYSERR, dir, "%s"); return (1); }
Upload File
Create Folder