Skip to content

Commit 9b1e173

Browse files
Merge pull request geekcomputers#204 from fanofxiaofeng/patch-3
deal with issue 200
2 parents 9dd098e + 275c144 commit 9b1e173

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

check_file.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,23 @@ def main():
3333
if len(sys.argv) >= 2:
3434
filenames = sys.argv[1:]
3535

36+
filteredfilenames = list(filenames)
3637
# Iterate for each filename passed in command line argument
3738
for filename in filenames:
3839
if not os.path.isfile(filename): # Check the File exists
3940
print('[-] ' + filename + ' does not exist.')
40-
filenames.remove(filename) #remove non existing files from fileNames list
41+
filteredfilenames.remove(filename) #remove non existing files from fileNames list
4142
continue
4243

4344
# Check you can read the file
4445
if not os.access(filename, os.R_OK):
4546
print('[-] ' + filename + ' access denied')
4647
# remove non readable fileNames
47-
filenames.remove(filename)
48+
filteredfilenames.remove(filename)
4849
continue
4950

50-
# Read the content of each file
51-
for filename in filenames:
51+
# Read the content of each file that both exists and is readable
52+
for filename in filteredfilenames:
5253
# Display Message and read the file contents
5354
print('[+] Reading from : ' + filename)
5455
readfile(filename)

0 commit comments

Comments
 (0)