コード例 #1
0
ファイル: findfiles.c プロジェクト: JamesSCrook/findfiles
/*******************************************************************************
Process a (file system) pathname (a file, directory or "other").
*******************************************************************************/
void process_path(char *pathname, regex_t *extregexpptr, int recursiondepth) {
	struct stat	statinfo;

	if (recursiondepth == 0) {
		trim_trailing_slashes(pathname);
	}

	if (!regularfileflag && !directoryflag && !otherobjectflag) {
		fprintf(stderr, "No output target types requested for '%s'!\n",pathname);
		returncode = 1;
		return;
	}

	if (lstat(pathname, &statinfo) == -1) {
		fprintf(stderr, "process_path: Cannot access '%s'\n", pathname);
		returncode = 1;
		return;
	}

	if (S_ISREG(statinfo.st_mode)) {
		if (regularfileflag) {
			process_object(pathname, extregexpptr);
		}
	} else if (S_ISDIR(statinfo.st_mode)) {
		if (directoryflag) {
			process_object(pathname, extregexpptr);
		}
		if (recursiondepth == 0 || (recursiveflag && recursiondepth <= maxrecursiondepth)) {
			process_directory(pathname, extregexpptr, recursiondepth);
		}
	} else if (otherobjectflag) {
		process_object(pathname, extregexpptr);
	}
}
コード例 #2
0
ファイル: syscall.c プロジェクト: kaltsi/rsync
int do_mkdir(char *fname, mode_t mode)
{
	if (dry_run) return 0;
	RETURN_ERROR_IF_RO_OR_LO;
	trim_trailing_slashes(fname);
	return mkdir(fname, mode);
}
コード例 #3
0
ファイル: trimslash.c プロジェクト: drasch/rsync-inplace
/**
 * @file trimslash.c
 *
 * Test harness; not linked into release.
 **/
int main(int argc, char **argv)
{
	int i;
	
	if (argc <= 1) {
		fprintf(stderr, "trimslash: needs at least one argument\n");
		return 1;
	}

	for (i = 1; i < argc; i++) {
		trim_trailing_slashes(argv[i]);	/* modify in place */
		printf("%s\n", argv[i]);
	}
	return 0;
}