Browse files

Implement the hideous voodoo that makes this work

and fill the pod with reasons and examples.
  • Loading branch information...
1 parent 9c411b1 commit d21b82295bf5139a0828771a666bd9a0403cce3b @rwstauner committed Jun 28, 2011
Showing with 45 additions and 1 deletion.
  1. +45 −1 lib/File/Spec/
46 lib/File/Spec/
@@ -3,12 +3,56 @@ use strict;
use warnings;
package File::Spec::Native;
-# ABSTRACT: undef
+# ABSTRACT: Use native OS implementation of File::Spec from a subclass
+use File::Spec (); #core
+our @ISA = qw(File::Spec);
+# TODO: import? -as => NATIVE
+=for test_synopsis
+my ($win32_path, $file_path);
+ # This serves little purpose on its own but can be useful in some situations
+ # For example:
+ use Path::Class 0.24;
+ # convert foreign file type into native type
+ # without having to know what the current OS is
+ foreign_file(Win32 => $win32_path)->as_foreign("Native");
+ # or to build a file-spec dynamically (possibly taking the type from input):
+ $type = get_requested_file_spec; # can return "Native"
+ foreign_file($type => $file_path);
+ # having $type be "Native" is an alternative to having to do:
+ my $file = $type ? foreign_file($type, $file_path) : file($file_path);
+This module is a stupid hack to make the default L<File::Spec> behavior
+available from a subclass. This can be useful when using another module
+that expects a subclass of L<File::Spec> but you want to use
+the current, native OS format (automatically detected by L<File::Spec>).
+For example: L<Path::Class/as_foreign> (as of version 0.24)
+allows you to translate a L<Path::Class> object from one OS format to another.
+However, there is no way way to specify that you want to translate the path into
+the current, native OS format without guessing at what that format is
+(which may include peeking into C<@File::Spec::ISA>).
+This module C<@ISA> L<File::Spec>.
+=head1 SEE ALSO
+=for :list
+* L<File::Spec>
+* L<Path::Class>
+* L<>

0 comments on commit d21b822

Please sign in to comment.