私は、ユーザーから2つの入力を受け取るpythonを使用して簡単なプログラムを作成しています:- ユーザーが検索したいファイルの名前であるファイル名。ユーザーがファイルを検索したいパスであるパス名。コードで os モジュールを使用しています。しかし、プログラムがショートカットでファイルを検索しないようにしたいです。では、フォルダがショートカットかどうかを確認する方法はありますか? 以下の関数の定義を投稿しています:
def searchwithex(path, filen):
global globalFileVal
global globalFileList
global count
dirCounter = checkdir(path) # checks whether the path is accesible or not.
if dirCounter == True:
topList = listdir(path)
for items in topList:
count += 1
if filen == items:
globalFileVal = path +'/' + items
globalFileList.append(globalFileVal)
items = path + '/' + items
if os.path.isdir(items): # checks whether the given element is a #file or a directory.
counter = searchwithex(items, filen)