Skip to content

Instantly share code, notes, and snippets.

@dagolden
Created November 9, 2014 03:30
Show Gist options
  • Save dagolden/72e21770f41afb438938 to your computer and use it in GitHub Desktop.
Save dagolden/72e21770f41afb438938 to your computer and use it in GitHub Desktop.
path_looks_legal
sub path_looks_legal {
my ($path) = @_;
my @native = File::Spec->splitpath($path);
my @unix = File::Spec::Unix->splitpath($path);
return if sum( map { $native[$_] ne $unix[$_] ? 1 : 0 } 0 .. 2 );
@native = File::Spec->splitdir($native[1]);
@unix = File::Spec::Unix->splitdir($unix[1]);
return if sum( map { $native[$_] ne $unix[$_] ? 1 : 0 } 0 .. 2 );
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment