Skip to content

Instantly share code, notes, and snippets.

@mattn
Created June 9, 2009 05:36
Show Gist options
  • Save mattn/126292 to your computer and use it in GitHub Desktop.
Save mattn/126292 to your computer and use it in GitHub Desktop.
path workaround for windows
From eeca3c96a2c73d4ba901b0056060a530c38a2dd4 Mon Sep 17 00:00:00 2001
From: mattn <[email protected]>
Date: Tue, 9 Jun 2009 14:39:45 +0900
Subject: [PATCH] path workaround for windows.
---
lib/Ark/Command/Interface.pm | 7 ++++++-
lib/Ark/Command/Server.pm | 7 ++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/lib/Ark/Command/Interface.pm b/lib/Ark/Command/Interface.pm
index 10f2d7a..95f9521 100644
--- a/lib/Ark/Command/Interface.pm
+++ b/lib/Ark/Command/Interface.pm
@@ -51,7 +51,12 @@ sub search_app {
return if $app;
return unless -f $file && $file->basename =~ /\.pm$/;
- (my $module = $file) =~ s!^$libdir/!!;
+ my $path = $libdir;
+ if ($^O eq 'MSWin32') {
+ $file =~ s!\\!/!g;
+ $path =~ s!\\!/!g;
+ }
+ (my $module = $file) =~ s!^$path/!!;
$module =~ s!/!::!g;
$module =~ s!\.pm$!!;
diff --git a/lib/Ark/Command/Server.pm b/lib/Ark/Command/Server.pm
index d99fa62..96fefa9 100644
--- a/lib/Ark/Command/Server.pm
+++ b/lib/Ark/Command/Server.pm
@@ -45,7 +45,12 @@ sub run {
return if $app_name;
return unless -f $file && $file->basename =~ /\.pm$/;
- (my $module = $file) =~ s!^$libdir/!!;
+ my $path = $libdir;
+ if ($^O eq 'MSWin32') {
+ $file =~ s!\\!/!g;
+ $path =~ s!\\!/!g;
+ }
+ (my $module = $file) =~ s!^$path/!!;
$module =~ s!/!::!g;
$module =~ s!\.pm$!!;
--
1.6.3.msysgit.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment