File-BSDGlob

 view release on metacpan or  search on metacpan

bsd_glob.c  view on Meta::CPAN

 */

#include <EXTERN.h>
#include <perl.h>
#include "bsd_glob.h"
#ifdef I_PWD
#	include <pwd.h>
#else
#ifdef HAS_PASSWD
	struct passwd *getpwnam _((char *));
	struct passwd *getpwuid _((Uid_t));
#endif
#endif

#ifndef MAXPATHLEN
#  ifdef PATH_MAX
#    define	MAXPATHLEN	PATH_MAX
#  else
#    define	MAXPATHLEN	1024
#  endif
#endif

bsd_glob.c  view on Meta::CPAN


	*h = EOS;

	if (((char *) patbuf)[0] == EOS) {
		/*
		 * handle a plain ~ or ~/ by expanding $HOME
		 * first and then trying the password file
		 */
		if ((h = getenv("HOME")) == NULL) {
#ifdef HAS_PASSWD
			if ((pwd = getpwuid(getuid())) == NULL)
				return pattern;
			else
				h = pwd->pw_dir;
#else
                        return pattern;
#endif
		}
	}
	else {
		/*

t/basic.t  view on Meta::CPAN

@a = File::BSDGlob::glob("*", 0);
@a = sort @a;
if ("@a" ne "@correct" || GLOB_ERROR) {
    print "# |@a| ne |@correct|\nnot ";
}
print "ok 2\n";

# look up the user's home directory
# should return a list with one item, and not set ERROR
if ($^O ne 'MSWin32') {
    ($name, $home) = (getpwuid($>))[0,7];
    @a = File::BSDGlob::glob("~$name", GLOB_TILDE);
    if (scalar(@a) != 1 || $a[0] ne $home || GLOB_ERROR) {
	print "not ";
    }
}
print "ok 3\n";

# check backslashing
# should return a list with one item, and not set ERROR
@a = File::BSDGlob::glob('BSDGlob\.pm', GLOB_QUOTE);



( run in 0.264 second using v1.01-cache-2.11-cpan-8d75d55dd25 )