Esempio n. 1
0
static void ScandirNCAT(PCStr(path),PCStr(rdir),scanDirCallP func,PCStr(arg))
{	FileStat st;

	stat(path,&st);
	Scandir(rdir,func,arg);
	set_utimes(path,st.st_atime,st.st_mtime);
}
Esempio n. 2
0
File: tdir.c Progetto: avokhmin/RPM5
static int dirWalk(const char * dn)
{
    rpmop op = memset(alloca(sizeof(*op)), 0, sizeof(*op));
    int xx = rpmswEnter(op, 0);
    DIR * dir;
    struct dirent * dp;
    off_t d_off = -1;
    int nentries = 0;
    int rc = 1;

    if ((dir = Opendir(dn)) == NULL)
	goto exit;
    while ((dp = Readdir(dir)) != NULL) {
	if (nentries == 0)
	    d_off = Telldir(dir);
	printDir(dp, Telldir(dir), nentries++);
    }
#ifdef	NOISY
    nentries = 0;
    Rewinddir(dir);
    while ((dp = Readdir(dir)) != NULL)
	printDir(dp, Telldir(dir), nentries++);
    Seekdir(dir, d_off);
    while ((dp = Readdir(dir)) != NULL) {
	printDir(dp, Telldir(dir), 0);
	break;
    }
#endif
    rc = Closedir(dir);

#ifdef	REFERENCE
    {	struct dirent ** dirents = NULL;
	int i;

	nentries = Scandir(dn, &dirents, NULL, Alphasort);
	for (i = 0; i < nentries; i++) {
	    dp = dirents[i];
	    printDir(dp, dp->d_off, i);
	    dirents[i] = _free(dirents[i]);
	}
	dirents = _free(dirents);
    }
#endif

exit:
    xx = rpmswExit(op, nentries);

fprintf(stderr, "===== %s: %d entries\n", dn, nentries);
    if (_rpmsw_stats)
	rpmswPrint("opendir:", op, NULL);
    return rc;
}
Esempio n. 3
0
/*
static int dir1(PCStr(cwd),PCStr(dir),PCStr(rdir),int dev,int ino,FILE *out,int *blocks)
*/
static int dir1(DA *da,PCStr(cwd),PCStr(dir),PCStr(rdir),int dev,int ino,FILE *out,int *blocks)
{	DA dab;
	CStr(pcwd,1024);
	CStr(dirbuf,1024);

	*blocks = 0;
	if( chdir(rdir) != 0 ){
		errlog("can't chdir: %s\n",dir);
		return 0;
	}
	if( !isFullpath(cwd) ){
		mkabspath(AVStr(pcwd),CWD,cwd);
		cwd = pcwd;
	}

	if( da ){
		dab.d_Root = da->d_Root;
		dab.d_Rlen = da->d_Rlen;
	}
	dab.d_top = 0;
	dab.d_out = out;
	dab.d_cwd = dir;
	dab.d_dev = dev;
	dab.d_ino = ino;
	dab.d_blocks = 0;
	dab.d_nch = 0;
	dab.d_nrm = 0;
	dab.d_lev = DIRLEV;
	DIRLEV++;
	if( F_UATIME )
		Scandir(".",scanDirCall find1,&dab);
	else{
		if( !isFullpath(dir) ){
			mkabspath(AVStr(dirbuf),CWD,dir);
			dir = dirbuf;
		}
		ScandirNCAT(dir,".",scanDirCall find1,(char*)&dab);
	}
	DIRLEV--;

	if( chdir(cwd) != 0 ){
		errlog("can't return to: %s\n",cwd);
		exit(-1);
	}
	*blocks = dab.d_blocks;
	return dab.d_nch == dab.d_nrm;
}
Esempio n. 4
0
static void sort_ls(PCStr(dirpath),LsArg *lsa)
{	int li;
	const char *line;

	lsa->l_nfill = 0;
	lsa->l_nsize = 0;
	lsa->l_lines = NULL;

	Scandir(dirpath,scanDirCall ls2,lsa);
	qsort(lsa->l_lines,lsa->l_nfill,sizeof(Elem),(sortFunc)cmpline);

	for( li = 0; li < lsa->l_nfill; li++ ){
		line = lsa->l_lines[li].s_line;
		fprintf(lsa->l_out,"%s\r\n",line);
		free((char*)line);
		free((char*)lsa->l_lines[li].s_skey);
	}
	free(lsa->l_lines);
}
Esempio n. 5
0
static void ino_name(PCStr(dir),int ino,PVStr(name))
{
	setVStrEnd(name,0);
	Scandir(dir,scanDirCall inofind1,ino,AVStr(name));
}