本文整理汇总了C++中dirstat函数的典型用法代码示例。如果您正苦于以下问题:C++ dirstat函数的具体用法?C++ dirstat怎么用?C++ dirstat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dirstat函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: confirm
static int /* boolean */
confirm(File *src, File *dest)
{
int absent, n, tty = eopen(TTY, 2);
char c, junk;
Dir *stp;
if ((stp = dirstat(src->name)) == nil)
sysfatal("no input file %s: %r", src->name);
free(stp);
stp = dirstat(dest->name);
absent = (stp == nil);
free(stp);
fprint(2, "%s: copy %s to %s%s? ", argv0, src->name, dest->name,
(absent? " (missing)": ""));
n = read(tty, &c, 1);
junk = c;
if (n < 1)
c = 'n';
while (n > 0 && junk != '\n')
n = read(tty, &junk, 1);
close(tty);
if (isascii(c) && isupper(c))
c = tolower(c);
return c == 'y';
}
开发者ID:bhanug,项目名称:harvey,代码行数:26,代码来源:ecp.c
示例2: main
void
main(int argc, char **argv)
{
int fd, ofd;
char diffout[40], idiffout[40];
Biobuf *b1, *b2, bdiff, bout, bstdout;
Dir *d;
ARGBEGIN{
default:
usage();
case 'b':
diffbflag++;
break;
case 'w':
diffwflag++;
break;
}ARGEND
if(argc != 2)
usage();
if((d = dirstat(argv[0])) == nil)
sysfatal("stat %s: %r", argv[0]);
if(d->mode&DMDIR)
sysfatal("%s is a directory", argv[0]);
free(d);
if((d = dirstat(argv[1])) == nil)
sysfatal("stat %s: %r", argv[1]);
if(d->mode&DMDIR)
sysfatal("%s is a directory", argv[1]);
free(d);
if((b1 = Bopen(argv[0], OREAD)) == nil)
sysfatal("open %s: %r", argv[0]);
if((b2 = Bopen(argv[1], OREAD)) == nil)
sysfatal("open %s: %r", argv[1]);
strcpy(diffout, "/tmp/idiff.XXXXXX");
fd = opentemp(diffout, ORDWR|ORCLOSE, 0);
strcpy(idiffout, "/tmp/idiff.XXXXXX");
ofd = opentemp(idiffout, ORDWR|ORCLOSE, 0);
rundiff(argv[0], argv[1], fd);
seek(fd, 0, 0);
Binit(&bdiff, fd, OREAD);
Binit(&bout, ofd, OWRITE);
idiff(b1, argv[0], b2, argv[1], &bdiff, diffout, &bout, idiffout);
Bterm(&bdiff);
Bflush(&bout);
seek(ofd, 0, 0);
Binit(&bout, ofd, OREAD);
Binit(&bstdout, 1, OWRITE);
copy(&bout, idiffout, &bstdout, "<stdout>");
exits(nil);
}
开发者ID:99years,项目名称:plan9,代码行数:55,代码来源:idiff.c
示例3: mkdir
void
mkdir(char *name, uint32_t mode, uint32_t mtime, char *uid,
char *gid)
{
Dir *d, xd;
int fd;
char *p;
char olderr[256];
fd = create(name, OREAD, mode);
if(fd < 0){
rerrstr(olderr, sizeof(olderr));
if((d = dirstat(name)) == nil || !(d->mode & DMDIR)){
free(d);
warn("can't make directory %q, mode %luo: %s", name, mode, olderr);
return;
}
free(d);
}
close(fd);
d = &xd;
nulldir(d);
p = utfrrune(name, L'/');
if(p)
p++;
else
p = name;
d->name = p;
if(uflag){
d->uid = uid;
d->gid = gid;
}
if(Tflag)
d->mtime = mtime;
d->mode = mode;
if(dirwstat(name, d) < 0)
warn("can't set modes for %q: %r", name);
if(uflag||Tflag){
if((d = dirstat(name)) == nil){
warn("can't reread modes for %q: %r", name);
return;
}
if(Tflag && d->mtime != mtime)
warn("%q: time mismatch %lu %lu\n", name, mtime, d->mtime);
if(uflag && strcmp(uid, d->uid))
warn("%q: uid mismatch %q %q", name, uid, d->uid);
if(uflag && strcmp(gid, d->gid))
warn("%q: gid mismatch %q %q", name, gid, d->gid);
}
}
开发者ID:aahud,项目名称:harvey,代码行数:52,代码来源:mkext.c
示例4: main
void
main(int argc, char *argv[])
{
int i, failed;
Dir *dirto, *dirfrom;
char *todir, *toelem;
if(argc<3){
fprint(2, "usage: mv fromfile tofile\n");
fprint(2, " mv fromfile ... todir\n");
exits("bad usage");
}
/* Skip -f */
if(argv[1][0] == '-' && argv[1][1] == 'f' && argv[1][2] == 0) {
for(i=2; i<argc; i++) {
argv[i-1] = argv[i];
}
argc--;
}
/* prepass to canonicalise names before splitting, etc. */
for(i=1; i < argc; i++)
cleanname(argv[i]);
if((dirto = dirstat(argv[argc-1])) != nil && (dirto->mode&DMDIR)){
dirfrom = nil;
if(argc == 3
&& (dirfrom = dirstat(argv[1])) != nil
&& (dirfrom->mode & DMDIR))
split(argv[argc-1], &todir, &toelem); /* mv dir1 dir2 */
else{ /* mv file... dir */
todir = argv[argc-1];
toelem = nil; /* toelem will be fromelem */
}
free(dirfrom);
}else
split(argv[argc-1], &todir, &toelem); /* mv file1 file2 */
free(dirto);
if(argc>3 && toelem != nil){
fprint(2, "mv: %s not a directory\n", argv[argc-1]);
exits("bad usage");
}
failed = 0;
for(i=1; i < argc-1; i++)
if(mv(argv[i], todir, toelem) < 0)
failed++;
if(failed)
exits("failure");
exits(0);
}
开发者ID:elbing,项目名称:apex,代码行数:52,代码来源:mv.c
示例5: readalljobs
void
readalljobs(void)
{
User *u;
Dir *d, *du;
char file[128];
int i, n, fd;
fd = open("/cron", OREAD);
if(fd < 0)
fatal("can't open /cron: %r");
while((n = dirread(fd, &d)) > 0){
for(i = 0; i < n; i++){
if(strcmp(d[i].name, "log") == 0 ||
!(d[i].qid.type & QTDIR))
continue;
if(strcmp(d[i].name, d[i].uid) != 0){
syslog(1, CRONLOG, "cron for %s owned by %s",
d[i].name, d[i].uid);
continue;
}
u = newuser(d[i].name);
snprint(file, sizeof file, "/cron/%s/cron", d[i].name);
du = dirstat(file);
if(du == nil || qidcmp(u->lastqid, du->qid) != 0){
freejobs(u->jobs);
u->jobs = readjobs(file, u);
}
free(du);
}
free(d);
}
close(fd);
}
开发者ID:99years,项目名称:plan9,代码行数:34,代码来源:cron.c
示例6: xdirstat0
static Dir*
xdirstat0(char **path, int (*namecmp)(char *, char *), char *err)
{
char *base, *name;
Dir *d, *t;
int n, i;
if(d = dirstat(*path))
return d;
if(!splitpath(*path, &base, &name))
return nil;
if((n = xdirread0(&base, namecmp, &t)) < 0)
goto out;
for(i=0; i<n; i++){
if(namecmp(t[i].name, name))
continue;
free(*path); *path = conspath(base, t[i].name);
d = xdirdup(&t[i], 1);
goto out;
}
werrstr("%s", err);
out:
free(base);
free(name);
return d;
}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:26,代码来源:dir.c
示例7: main
void
main(int argc, char *argv[])
{
int i;
int recurse;
char *f;
Dir *db;
ignerr = 0;
recurse = 0;
ARGBEGIN{
case 'r':
recurse = 1;
break;
case 'f':
ignerr = 1;
break;
default:
fprint(2, "usage: rm [-fr] file ...\n");
exits("usage");
}ARGEND
for(i=0; i<argc; i++){
f = argv[i];
if(remove(f) != -1)
continue;
if((db = dirstat(f)) == nil || (db->qid.type&QTDIR) ==0)
err(f);
else if(RemoveDirectory(f) == 0)
if(recurse)
Ntrmdir(f);
else
err(f);
}
exits(errbuf);
}
开发者ID:JamesLinus,项目名称:inferno,代码行数:35,代码来源:rm-Nt.c
示例8: corefile
void
corefile(char *name, int explicit)
{
Fhdr *hdr;
char t[100];
Dir *d;
if((d = dirstat(name)) == nil){
if(explicit)
fprint(2, "%s; %r\n", name);
return;
}
strcpy(t, ctime(d->mtime));
t[strlen(t)-1] = 0; /* newline */
if((hdr = crackhdr(name, OREAD)) == nil){
if(explicit)
fprint(2, "%s: %r\n", name);
return;
}
if(hdr->ftype != FCORE){
uncrackhdr(hdr);
if(explicit)
fprint(2, "%s: not a core file\n", name);
return;
}
开发者ID:00001,项目名称:plan9port,代码行数:26,代码来源:core.c
示例9: coreall
void
coreall(char *name)
{
Dir *d;
int fd, i, n;
char *p;
if((d = dirstat(name)) == nil){
fprint(2, "%s: %r\n", name);
return;
}
if((d->mode&DMDIR) == 0){
free(d);
corefile(name, 1);
return;
}
free(d);
if((fd = open(name, OREAD)) < 0){
fprint(2, "open %s: %r\n", name);
return;
}
n = dirreadall(fd, &d);
qsort(d, n, sizeof(d[0]), timecmp);
for(i=0; i<n; i++){
p = smprint("%s/%s", name, d[i].name);
if(p == nil)
sysfatal("out of memory");
corefile(p, 0);
free(p);
}
}
开发者ID:00001,项目名称:plan9port,代码行数:31,代码来源:core.c
示例10: openlock
static int
openlock(char *lock)
{
int lckfd;
Dir *dir;
/* first ensure that the lock file has the lock bit set */
dir = dirstat(lock);
if (dir == nil)
sysfatal("can't stat %s: %r", lock);
if (!(dir->mode & DMEXCL)) {
dir->mode |= DMEXCL;
dir->qid.type |= QTEXCL;
if (dirwstat(lock, dir) < 0)
sysfatal("can't make %s exclusive access: %r", lock);
}
free(dir);
if (lockwait)
while ((lckfd = open(lock, ORDWR)) < 0)
sleep(1000);
else
lckfd = open(lock, ORDWR);
if (lckfd < 0)
sysfatal("can't open %s read/write: %r", lock);
return lckfd;
}
开发者ID:aahud,项目名称:harvey,代码行数:27,代码来源:lock.c
示例11: dirtime
void
dirtime(char *dir, char *path)
{
Dir d;
void *t;
char buf[8192];
HANDLE handle;
WIN32_FIND_DATA wfd;
snprint(buf, sizeof(buf), "%s/*.*", dir);
handle = FindFirstFile(buf, &wfd);
if(handle == INVALID_HANDLE_VALUE)
return;
do {
sprint(buf, "%s%s", path, wfd.cFileName);
if(dirstat(buf, &d) < 0)
continue;
t = (void *)d.mtime;
if (!t) /* zero mode file */
continue;
if(symlook(buf, S_TIME, 0))
continue;
symlook(strdup9(buf), S_TIME, t)->value = t;
} while(FindNextFile(handle, &wfd) == TRUE);
FindClose(handle);
}
开发者ID:aryx,项目名称:fork-c--,代码行数:28,代码来源:Nt.c
示例12: access
int
access(char *name, int mode)
{
int fd;
Dir *db;
static char omode[] = {
0,
OEXEC,
OWRITE,
ORDWR,
OREAD,
OEXEC, /* only approximate */
ORDWR,
ORDWR /* only approximate */
};
if(mode == AEXIST){
db = dirstat(name);
free(db);
if(db != nil)
return 0;
return -1;
}
fd = open(name, omode[mode&7]);
if(fd >= 0){
close(fd);
return 0;
}
return -1;
}
开发者ID:99years,项目名称:plan9,代码行数:30,代码来源:access.c
示例13: removeall
void
removeall(char *p)
{
int fd, n, i;
Dir *d;
char *q;
if(remove(p) >= 0)
return;
if((d = dirstat(p)) == nil)
return;
if(!(d->mode & DMDIR)) {
free(d);
return;
}
free(d);
if((fd = open(p, OREAD)) < 0)
return;
n = dirreadall(fd, &d);
close(fd);
for(i=0; i<n; i++) {
q = smprint("%s/%s", p, d[i].name);
removeall(q);
free(q);
}
free(d);
}
开发者ID:8l,项目名称:go,代码行数:28,代码来源:tempdir_plan9.c
示例14: acmetimer
/*
* Depends on d.qid.vers being highest numbered message in dir.
*/
void
acmetimer(Article *m, Window *w)
{
Biobuf *b;
Dir *d;
assert(m==nil && w==root);
if((d = dirstat(dir))==nil | hi==d->qid.vers){
free(d);
return;
}
if(w->data < 0)
w->data = winopenfile(w, "data");
if(winsetaddr(w, "0", 0))
write(w->data, "", 0);
b = emalloc(sizeof(*b));
Binit(b, w->data, OWRITE);
adddir(b, d->qid.vers, hi+1, d->qid.vers);
hi = d->qid.vers;
Bterm(b);
free(b);
free(d);
winselect(w, "0,.", 0);
}
开发者ID:carriercomm,项目名称:plan9-gpl,代码行数:30,代码来源:news.c
示例15: getPath
char*
getPath(char* command)
// Search for `command` on the different directories specified on the path and
// return the executable full path.
// If command is not found, it returns the last processed full path
{
char* env = getenv(ENV_PATH);
char* array[10];
int numTokens = gettokens(env, array, 10, PATH_TOKEN_SPLIT);
char* path = calloc(256, sizeof(char));
int i;
for(i = 0; i < numTokens; ++i)
{
// Calc command path
strncpy(path, array[i],256);
strncat(path, "/", 256);
strncat(path, command, 256);
// If command exists at dir, return it
Dir* d = dirstat(path);
free(d);
if(d) // We are only interested on the pointer, not on it's content...
break;
}
free(env);
return path;
}
开发者ID:ChaOS-Project,项目名称:P9sh,代码行数:31,代码来源:command.c
示例16: cdDirstat
Dir*
cdDirstat(char *dir, char *file)
{
if(myChdir(dir) < 0)
return nil;
return dirstat(file);
}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:7,代码来源:folder.c
示例17: removefile
static int
removefile(SConn *conn, char *id, char *f)
{
Dir *d;
char buf[Maxmsg];
snprint(buf, Maxmsg, "%s/store/%s/%s", SECSTORE_DIR, id, f);
if((d = dirstat(buf)) == nil){
snprint(buf, sizeof buf, "remove failed: %r");
writerr(conn, buf);
return -1;
}else if(d->mode & DMDIR){
snprint(buf, sizeof buf, "can't remove a directory");
writerr(conn, buf);
free(d);
return -1;
}
free(d);
if(remove(buf) < 0){
snprint(buf, sizeof buf, "remove failed: %r");
writerr(conn, buf);
return -1;
}
return 0;
}
开发者ID:99years,项目名称:plan9,代码行数:27,代码来源:secstored.c
示例18: auth_getkey
int
auth_getkey(char *params)
{
char *name;
Dir *d;
int pid;
Waitmsg *w;
/* start /factotum to query for a key */
name = "/factotum";
d = dirstat(name);
if(d == nil){
name = "/boot/factotum";
d = dirstat(name);
}
if(d == nil){
werrstr("auth_getkey: no /factotum or /boot/factotum: didn't get key %s", params);
return -1;
}
if(0) if(d->type != '/'){
werrstr("auth_getkey: /factotum may be bad: didn't get key %s", params);
return -1;
}
switch(pid = fork()){
case -1:
werrstr("can't fork for %s: %r", name);
return -1;
case 0:
execl(name, "getkey", "-g", params, nil);
exits(0);
default:
for(;;){
w = wait();
if(w == nil)
break;
if(w->pid == pid){
if(w->msg[0] != '\0'){
free(w);
return -1;
}
free(w);
return 0;
}
}
}
return 0;
}
开发者ID:99years,项目名称:plan9,代码行数:47,代码来源:auth_getkey.c
示例19: getdf
/*
* get a cracked dependency file
*/
Dfile*
getdf(char *path)
{
Dfile *df, **l;
QLock *lk;
Dir *d;
int i, fd;
Biobuf *b;
i = shash(path, Ndfhash);
l = &dfhash[i];
lk = &dfhlock[i];
qlock(lk);
for(df = *l; df; df = *l){
if(strcmp(path, df->path) == 0)
break;
l = &df->next;
}
d = dirstat(path);
if(df){
if(d!=nil && d->qid.type == df->qid.type && d->qid.vers == df->qid.vers && d->qid.vers == df->qid.vers){
free(path);
lock(df);
df->use++;
unlock(df);
goto Return;
}
*l = df->next;
freedf(df);
}
fd = open(path, OREAD);
if(d == nil || fd < 0){
close(fd);
goto Return;
}
df = emalloc(sizeof(*df));
b = emalloc(sizeof(Biobuf));
Binit(b, fd, OREAD);
df->qid = d->qid;
df->path = path;
crackdf(df, b, d->length, path);
Bterm(b);
free(b);
df->next = *l;
*l = df;
df->use = 1;
Return:
qunlock(lk);
free(d);
return df;
}
开发者ID:99years,项目名称:plan9,代码行数:60,代码来源:depend.c
示例20: wdirstat
Dir*
wdirstat(char *fn)
{
Dir *d;
fn = wname(fn);
d = dirstat(fn);
free(fn);
return d;
}
开发者ID:aahud,项目名称:harvey,代码行数:10,代码来源:wdir.c
注:本文中的dirstat函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论