Permalink
Browse files

Make stupid tools keep stupid BBEdit creator and TEXT type

Optional.  See Slash::Tools::CONFIG.
  • Loading branch information...
1 parent 78c747f commit 3e4e3c128645c68f69dbff347cc90345c5bfdf61 @pudge pudge committed May 23, 2008
Showing with 30 additions and 0 deletions.
  1. +30 −0 Slash/Tools/Tools.pm
View
@@ -21,8 +21,13 @@ our @EXPORT = qw(
pmpath pathpm pmpathsrc counterpart srcfile installfile basefile
basefile basename dirname
syntax_check %CONFIG
+ @BIN_EXT $BIN_EXT $BIN_RE
);
+our @BIN_EXT = qw(gz tgz bz2 gif jpg png ico);
+our $BIN_EXT = join '|', @BIN_EXT;
+our $BIN_RE = qr/\.(?:$BIN_EXT)$/;
+
my(%cache);
# if cache gets stale, you can use force => 0, or heck, just
# rm ~/.slash_tools_cache
@@ -324,6 +329,31 @@ sub diff {
}
}
+
+package Slash::Tools::Mac;
+
+sub new {
+ require MacPerl;
+ shift;
+ my $self = bless { @_ }, __PACKAGE__;
+ $self->{creator} ||= 'R*ch';
+ $self;
+}
+
+sub set_type {
+ my $self = shift;
+ return unless $self->{creator};
+
+ my($file) = @_;
+ return if $file =~ $BIN_RE;
+
+ my($creator, $type) = MacPerl::GetFileInfo($file);
+ return if $creator && $type && $creator eq $self->{creator} && $type eq 'TEXT';
+
+ MacPerl::SetFileInfo($self->{creator}, 'TEXT', $file);
+}
+
+
1;

0 comments on commit 3e4e3c1

Please sign in to comment.