mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-08 14:48:32 -04:00
DBD-SQLite: better unicode path handling under cygwin (resolved #45166)
This commit is contained in:
parent
ab521c5c97
commit
3bb67972ff
3 changed files with 33 additions and 11 deletions
|
@ -212,6 +212,9 @@ WriteMakefile(
|
|||
( WINLIKE ? (
|
||||
'Win32' => '0.30',
|
||||
) : () ),
|
||||
( ($^O eq 'cygwin' && $] < 5.010) ? (
|
||||
'Filesys::CygwinPaths' => '0',
|
||||
) : () ),
|
||||
},
|
||||
OPTIONAL( '6.48',
|
||||
MIN_PERL_VERSION => '5.006',
|
||||
|
|
|
@ -65,7 +65,7 @@ sub connect {
|
|||
|
||||
# To avoid unicode and long file name problems on Windows,
|
||||
# convert to the shortname if the file (or parent directory) exists.
|
||||
if ( $^O eq 'MSWin32' and $real ne ':memory:' ) {
|
||||
if ( $^O =~ /MSWin32|cygwin/ and $real ne ':memory:' ) {
|
||||
require Win32;
|
||||
require File::Basename;
|
||||
my ($file, $dir, $suffix) = File::Basename::fileparse($real);
|
||||
|
@ -81,6 +81,15 @@ sub connect {
|
|||
# SQLite can't do mkpath anyway.
|
||||
# So let it go through as it and fail.
|
||||
}
|
||||
if ( $^O eq 'cygwin' ) {
|
||||
if ( $] >= 5.010 ) {
|
||||
$real = Cygwin::win_to_posix_path($real, 'absolute');
|
||||
}
|
||||
else {
|
||||
require Filesys::CygwinPaths;
|
||||
$real = Filesys::CygwinPaths::fullposixpath($real);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Hand off to the actual login function
|
||||
|
|
|
@ -74,18 +74,28 @@ foreach my $subdir ( 'longascii', 'adatb
|
|||
|
||||
sub _path { # copied from DBD::SQLite::connect
|
||||
my $path = shift;
|
||||
return $path unless $^O eq 'MSWin32';
|
||||
|
||||
require Win32;
|
||||
require File::Basename;
|
||||
if ($^O =~ /MSWin32|cygwin/) {
|
||||
require Win32;
|
||||
require File::Basename;
|
||||
|
||||
my ($file, $dir, $suffix) = File::Basename::fileparse($path);
|
||||
my $short = Win32::GetShortPathName($path);
|
||||
if ( $short && -f $short ) {
|
||||
# Existing files will work directly.
|
||||
return $short;
|
||||
} elsif ( -d $dir ) {
|
||||
return join '', grep { defined } Win32::GetShortPathName($dir), $file, $suffix;
|
||||
my ($file, $dir, $suffix) = File::Basename::fileparse($path);
|
||||
my $short = Win32::GetShortPathName($path);
|
||||
if ( $short && -f $short ) {
|
||||
# Existing files will work directly.
|
||||
$path = $short;
|
||||
} elsif ( -d $dir ) {
|
||||
$path = join '', grep { defined } Win32::GetShortPathName($dir), $file, $suffix;
|
||||
}
|
||||
if ($^O eq 'cygwin') {
|
||||
if ($] >= 5.010) {
|
||||
$path = Cygwin::win_to_posix_path($path, 'absolute');
|
||||
}
|
||||
else {
|
||||
require Filesys::CygwinPaths;
|
||||
$path = Filesys::CygwinPaths::fullposixpath($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $path;
|
||||
}
|
Loading…
Add table
Reference in a new issue