Skip to content

Commit

Permalink
add is_unix,is_dos; change tmpfile location on DOS
Browse files Browse the repository at this point in the history
  • Loading branch information
desmid committed Oct 4, 2019
1 parent e6cb5b6 commit 59d2a21
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bin/mview
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Release information
###########################################################################
my $VERSION = '1.66';
my $PATCH = '';
my $PATCH = '1';
my $PROJECT = 'MView';
my $AUTHOR = "Nigel P. Brown";
my $VERSION = $VERSION . ($PATCH ? ".$PATCH" : "");
Expand All @@ -34,7 +34,7 @@ use strict;

###########################################################################
my $PROG = basename($0);
my $TMPFILE = tmpfile("mview_$$");
my $TMPFILE = tmpfile();
my $INVOCATION = "$PROG @ARGV";

###########################################################################
Expand Down
10 changes: 7 additions & 3 deletions lib/Bio/Util/File.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 1996-2018 Nigel P. Brown
# Copyright (C) 1996-2019 Nigel P. Brown

# This file is part of MView.
# MView is released under license GPLv2, or any later version.
Expand All @@ -10,6 +10,8 @@ package Bio::Util::File;

use Exporter;

use Bio::Util::System qw(is_unix is_dos);

use vars qw(@ISA @EXPORT_OK);

@ISA = qw(Exporter);
Expand Down Expand Up @@ -40,8 +42,10 @@ sub fileparts {

#temporary file name
sub tmpfile {
my ($s) = (@_, $$);
return "/tmp/$s" if $^O ne 'MSWin32';
my ($s) = (@_, "mview_$$");
return "/tmp/$s" if is_unix();
return "$ENV{'TEMP'}\\$s" if is_dos() and -d $ENV{'TEMP'};
return "$ENV{'TMP'}\\$s" if is_dos() and -d $ENV{'TMP'};
return $s;
}

Expand Down
19 changes: 17 additions & 2 deletions lib/Bio/Util/System.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 1996-2018 Nigel P. Brown
# Copyright (C) 1996-2019 Nigel P. Brown

# This file is part of MView.
# MView is released under license GPLv2, or any later version.
Expand All @@ -14,7 +14,7 @@ use vars qw(@ISA @EXPORT_OK);

@ISA = qw(Exporter);

@EXPORT_OK = qw(stacktrace vmstat);
@EXPORT_OK = qw(stacktrace vmstat is_unix is_dos);

sub stacktrace {
warn "Stack Trace:\n"; my $i = 0;
Expand All @@ -39,5 +39,20 @@ sub vmstat {
}
}

sub is_unix {
return 1
if grep {/$^O/i} qw(aix android bsdos beos bitrig dgux dynixptx cygwin
darwin dragonfly freebsd gnukfreebsd haiku hpux
interix irix linux machten midnightbsd minix
mirbsd netbsd next nto openbsd qnx sco solaris);
return 0;
}

sub is_dos {
return 1
if grep {/$^O/i} qw(dos MSWin32);
return 0;
}

###########################################################################
1;

0 comments on commit 59d2a21

Please sign in to comment.