[Pcsclite-git-commit] [pcsc-tools] 01/01: ATR_analysis: fix smartcard_list.txt first fetch

Ludovic Rousseau rousseau at moszumanska.debian.org
Fri Sep 8 15:38:22 UTC 2017


This is an automated email from the git hooks/post-receive script.

rousseau pushed a commit to branch master
in repository pcsc-tools.

commit 726279b986fc2c36a6c6d97991b96f9fcacc184e
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Fri Sep 8 16:35:27 2017 +0200

    ATR_analysis: fix smartcard_list.txt first fetch
    
    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.
---
 ATR_analysis | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/ATR_analysis b/ATR_analysis
index 1e49a29..397aa4e 100755
--- a/ATR_analysis
+++ b/ATR_analysis
@@ -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");
@@ -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
@@ -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";

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/pcsc-tools.git



More information about the Pcsclite-cvs-commit mailing list