Commits

Palmer, 2E0EOL committed d747f82 Draft

Write loop to loop over the password files

Comments (0)

Files changed (1)

 
 sub main();
 sub mktable($);
+sub read_textfile($);
+sub loopdir($$);
 
 sub mktable($)
 {
 	}
 }
 
+sub read_textfile($)
+{
+	my $filepath = shift;
+	printf(STDERR "Reading %s\n", $filepath);
+	return 1;
+}
+
+sub loopdir($$)
+{
+	my ( $dbh, $dirpath ) = @_;
+	if ( opendir(my $d, $dirpath) ) {
+		while ( my $ent = readdir($d) ) {
+			next if ( index($ent, '.') == 0 ); # Skip hidden files
+			printf(STDERR "Reading password file: %s\n", $ent);
+			read_textfile("$dirpath/$ent");
+		}
+		closedir($d);
+	}
+}
+
 sub main()
 {
 	my $dbfile = 'passwords.sqlite';
 	my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","", {});
 	mktable($dbh);
+	loopdir($dbh, $ENV{HOME} . '/private/passwords');
 	return 0;
 }