DBI

 view release on metacpan or  search on metacpan

lib/DBD/File.pm  view on Meta::CPAN

    my ($drh, $dbname, $user, $auth, $attr) = @_;

    # We do not (yet) care about conflicting attributes here
    # my $dbh = DBI->connect ("dbi:CSV:f_dir=test", undef, undef, { f_dir => "text" });
    # will test here that both test and text should exist
    #
    # Parsing on our own similar to parse_dsn to find attributes in 'dbname' parameter.
    if ($dbname) {
	my $attr_hash = {
	    map { (m/^\s* (\S+) \s*(?: =>? | , )\s* (\S*) \s*$/x) }
	    split m/;/ => $dbname };
	if (defined $attr_hash->{f_dir}) {
	    my $f_dir = $attr_hash->{f_dir};
	    # DSN escapes the : in Windows' path, which is not accepted by -d
	    #   D\\:\\\\Test\\\\DBI-01\\\\test_output_12345
	    # ->  D:\\\\Test\\\\DBI-01\\\\test_output_12345
	    $^O eq "MSWin32" and $f_dir =~ s{^([a-zA-Z])\\+:}{$1:};
	    unless (-d $f_dir) {
		my $msg = "No such directory '$attr_hash->{f_dir}";
		$drh->set_err (2, $msg);
		$attr_hash->{RaiseError} and croak $msg;

lib/DBD/File.pm  view on Meta::CPAN

my $fn_any_ext_regex = qr/\.[^.]*/;

sub complete_table_name {
    my ($self, $meta, $file, $respect_case, $file_is_table) = @_;

    $file eq "." || $file eq ".."	and return; # XXX would break a possible DBD::Dir

    # XXX now called without proving f_fqfn first ...
    my ($ext, $req) = ("", 0);
    if ($meta->{f_ext}) {
	($ext, my $opt) = split m{/}, $meta->{f_ext};
	if ($ext && $opt) {
	    $opt =~ m/r/i and $req = 1;
	    }
	}

    # (my $tbl = $file) =~ s/\Q$ext\E$//i;
    my ($tbl, $basename, $dir, $fn_ext, $user_spec_file, $searchdir);
    if ($file_is_table and defined $meta->{f_file}) {
	$tbl = $file;
	($basename, $dir, $fn_ext) = File::Basename::fileparse ($meta->{f_file}, $fn_any_ext_regex);



( run in 1.112 second using v1.01-cache-2.11-cpan-71847e10f99 )