Skip to content

Commit

Permalink
ATR_analysis: fix smartcard_list.txt first fetch
Browse files Browse the repository at this point in the history
If the user smartcard_list.txt (in ~/.cache/ by default) does not exist
then try to create the parent directory (~/.cache by default) first.

The parent directory may not exist yet and storing a file in a
non-existant directory does not work well.
  • Loading branch information
LudovicRousseau committed Sep 8, 2017
1 parent 12f84e8 commit 726279b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions ATR_analysis
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ sub update_smartcard_list($$)
{
print "Updating $file using $url\n";

if (! -e "$file")
{
# the file does not exist yet: create the parent directory
system("mkdir -p $Cache");
}

if ($^O =~ "darwin")
{
system("curl $url --output $file");
Expand All @@ -260,15 +266,6 @@ sub update_smartcard_list($$)

# find the corresponding card type
my $found = find_card($atr, @SMARTCARD_LIST);
if ($found == 2)
{
# no ATR file found
mkdir $Cache;

# continue with the ATR list update
$found = 1;
}

if ($found == 1)
{
# ATR not found
Expand Down Expand Up @@ -535,7 +532,7 @@ sub find_card($@)
}

# no valid file found
return 2 if (!defined $file);
return 1 if (!defined $file);

$found = 0;
print "\nPossibly identified card (using $file):\n";
Expand Down

0 comments on commit 726279b

Please sign in to comment.