Skip to content

Commit

Permalink
Reinclude realpath() call,make calls direct to Dancer::FileUtils::pat…
Browse files Browse the repository at this point in the history
…h_no_verify(),use double-dot range(more common than triple),simplify directory separator
  • Loading branch information
rowanthorpe committed Feb 12, 2011
1 parent f6fe3ee commit 5f52f5d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/Dancer.pm
Expand Up @@ -261,14 +261,14 @@ sub _init {
|| setting('appdir');

setting public => $ENV{DANCER_PUBLIC}
|| path_no_verify(setting('appdir'), 'public');
|| Dancer::FileUtils::path_no_verify(setting('appdir'), 'public');

setting views => $ENV{DANCER_VIEWS}
|| path_no_verify(setting('appdir'), 'views');
|| Dancer::FileUtils::path_no_verify(setting('appdir'), 'views');

setting logger => 'file';

my ($res, $error) = Dancer::ModuleLoader->use_lib(path_no_verify(setting('appdir'), 'lib'));
my ($res, $error) = Dancer::ModuleLoader->use_lib(Dancer::FileUtils::path_no_verify(setting('appdir'), 'lib'));
$res or croak "unable to set libdir : $error";
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Dancer/FileUtils.pm
Expand Up @@ -6,14 +6,15 @@ use warnings;
use File::Basename ();
use File::Spec;
use Carp;
use Cwd 'realpath';

use base 'Exporter';
use vars '@EXPORT_OK';

@EXPORT_OK = qw(path dirname read_file_content read_glob_content open_file);

sub path { File::Spec->catfile(@_) }
sub path_no_verify { File::Spec->catdir(@_[0...$#_-1]).File::Spec->catdir('').$_[-1] } # [0->?] path(must exist),[last] file(maybe exists)
sub path_no_verify { realpath(File::Spec->catdir(@_[0..$#_-1])).'/'.$_[-1] } # [0->?] path(must exist),[last] file(maybe exists)
sub dirname { File::Basename::dirname(@_) }

sub open_file {
Expand Down
5 changes: 3 additions & 2 deletions t/02_request/14_uploads.t
Expand Up @@ -3,6 +3,7 @@ use warnings;

use Dancer ':syntax';
use Dancer::Request;
use Dancer::FileUtils;
use Test::More 'import' => ['!pass'];


Expand Down Expand Up @@ -95,8 +96,8 @@ do {
$upload->copy_to($dest_file);
ok( ( -f $dest_file ), "file '$dest_file' has been copied" );

$upload->link_to( path_no_verify( $dest_dir, "hardlink" ) );
ok( ( -f path_no_verify( $dest_dir, "hardlink" ) ), "hardlink is created" );
$upload->link_to( Dancer::FileUtils::path_no_verify( $dest_dir, "hardlink" ) );
ok( ( -f Dancer::FileUtils::path_no_verify( $dest_dir, "hardlink" ) ), "hardlink is created" );

SKIP: {
skip "bogus upload tests on win32", 2 if ( $^O eq 'MSWin32' or $^O eq 'cygwin' );
Expand Down

0 comments on commit 5f52f5d

Please sign in to comment.