From nobody Mon Feb 9 21:19:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+65643+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+65643+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1601083733; cv=none; d=zohomail.com; s=zohoarc; b=nqSRdgGw5zl1D+rY2mquJ07jlQs/YEs0NplsgRjfN3KXks6C3xLbmfAx0jejIAGcYBN0+iNJpyTW3kmyoFGOcc2+t1buexGwb1qyvHoBDeTSgMmN8bW6fOiA0/eYnQv8ZXEVVaRadi+M9adCRufoKDs2ztNEb3DU+OaZxt3lUrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601083733; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=D82L1r+g8ucrsiYFhb2rQD0tJazs9zUzkwWNBkWXAZQ=; b=lrJnnuoxLx3i1yIp9Ofn/LUFNrAWGoIRXmZAgGGXShB4ah2CttuD1phDq/jAwRzA3IuzBxRXaLuwGcyErnkEDAA6/ZHqAKswLyNIP/hZwJGIa6pV10GHKRDA1fsI5aBKfR6LNl+t//VKPoqw+XqkAPNQHmCdQ5xSAWMi3N0fQ2A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+65643+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1601083733332814.2354370173746; Fri, 25 Sep 2020 18:28:53 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id YwPCYY1788612xrRfx0dimb0; Fri, 25 Sep 2020 18:28:52 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web10.2557.1601083731831999581 for ; Fri, 25 Sep 2020 18:28:51 -0700 IronPort-SDR: t2Fqd5TZOgr8u28i46GS90OzhywWjlG/6yar14o14Pd0j6k8eV5JmtKbVW1/Vi7DntNoaKKuEk dejJjwjYvSUw== X-IronPort-AV: E=McAfee;i="6000,8403,9755"; a="160930074" X-IronPort-AV: E=Sophos;i="5.77,303,1596524400"; d="scan'208";a="160930074" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2020 18:28:49 -0700 IronPort-SDR: ng1cmDkf7FGdU6QxoiPHafaFEx5ONFKOGoYsxth/UVhu2lqvr5xU5rDjS+1NqcW3uKJDbWvuRh ghfn7QVRFa7w== X-IronPort-AV: E=Sophos;i="5.77,303,1596524400"; d="scan'208";a="513245996" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.212.4.151]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2020 18:28:48 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Ashley E Desimone , Puja Pandya , Bret Barkelew , Prince Agyeman , Erik Bjorge Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH V3 1/2] EdkRepo: Add function to enumerate subst drives Date: Fri, 25 Sep 2020 18:28:25 -0700 Message-Id: <20200926012826.4976-2-nathaniel.l.desimone@intel.com> In-Reply-To: <20200926012826.4976-1-nathaniel.l.desimone@intel.com> References: <20200926012826.4976-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nathaniel.l.desimone@intel.com X-Gm-Message-State: yQ4zhTKflK9LABP1FqqCW8t5x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1601083732; bh=M4lNuddp60kMkxH7CDnUoRsBL9btd/YueZUWUAbOkoU=; h=Cc:Date:From:Reply-To:Subject:To; b=dJtLJsAV6kdVvbA26/JxXMYzPCWxpiBLmCcYAVSaw6tySeI7a82EO50m76V//AMKQlS SfDciRSZWvIORhNgpliYtU8xYLz85T8VnS2qi50FLT1pnnstJFiyr3UtoNnl64G7jZZlY jdpnws/cM8Vu+lnT6FpzkdBSwbvqa0YIw4E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Cc: Ashley E Desimone Cc: Puja Pandya Cc: Bret Barkelew Cc: Prince Agyeman Cc: Erik Bjorge Signed-off-by: Nate DeSimone Reviewed-by: Ashley DeSimone Reviewed-by: Erik Bjorge --- edkrepo/common/pathfix.py | 50 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/edkrepo/common/pathfix.py b/edkrepo/common/pathfix.py index 1a9c20f..2775442 100644 --- a/edkrepo/common/pathfix.py +++ b/edkrepo/common/pathfix.py @@ -3,7 +3,7 @@ ## @file # checkout_command.py # -# Copyright (c) 2018- 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # import os @@ -11,6 +11,7 @@ import sys if sys.platform =3D=3D "win32": from ctypes import windll, POINTER, byref, GetLastError, Structure, Wi= nError from ctypes import c_void_p, c_ushort, c_int, c_ulong, c_wchar, c_wch= ar_p + from ctypes import create_unicode_buffer =20 def _is_wow64_process(): kernel32 =3D windll.kernel32 @@ -211,3 +212,50 @@ def expanduser(path): userhome =3D os.path.join(os.path.dirname(userhome), path[1:i]) =20 return userhome + path[i:] + +def get_subst_drive_dict(): + if sys.platform !=3D "win32": + return {} + def _query_subst_drive(drive_letter): + kernel32 =3D windll.kernel32 + QueryDosDevice =3D kernel32.QueryDosDeviceW + QueryDosDevice.argtypes =3D [c_wchar_p, c_wchar_p, c_ulong] + QueryDosDevice.restype =3D c_ulong + MAX_PATH =3D 260 + + if len(drive_letter) > 1 or len(drive_letter) =3D=3D 0: + raise ValueError("Bad drive letter") + drive =3D '{}:'.format(drive_letter.upper()) + drive_buffer =3D create_unicode_buffer(drive) + target_path_buffer_size =3D c_ulong(MAX_PATH) + target_path_buffer =3D create_unicode_buffer(target_path_buffer_si= ze.value) + while True: + count =3D QueryDosDevice(drive_buffer, target_path_buffer, tar= get_path_buffer_size) + if count =3D=3D 0: + last_error =3D GetLastError() + if last_error =3D=3D 122: #ERROR_INSUFFICIENT_BUFFER + #Increase the buffer size and try again + target_path_buffer_size =3D c_ulong((target_path_buffe= r_size.value * 161) / 100) + target_path_buffer =3D create_unicode_buffer(target_pa= th_buffer_size.value) + elif last_error =3D=3D 2: #ERROR_FILE_NOT_FOUND + #This is an invalid drive, return an empty string + return '' + else: + raise WinError(last_error) + else: + break + target_path =3D target_path_buffer.value + if len(target_path) > 4 and target_path[0:4] =3D=3D '\\??\\': + if (ord(target_path[4]) >=3D ord('A') and ord(target_path[4]) = <=3D ord('Z')) or \ + (ord(target_path[4]) >=3D ord('a') and ord(target_path[4])= <=3D ord('z')): + #This is a SUBST'd drive, return the path + return target_path[4:].strip() + #This is a non-SUBST'd (aka real) drive, return an empty string + return '' + subst_dict =3D {} + for index in range(26): + drive_letter =3D chr(ord('A') + index) + target_path =3D _query_subst_drive(drive_letter) + if target_path !=3D '': + subst_dict[drive_letter] =3D target_path + return subst_dict --=20 2.27.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#65643): https://edk2.groups.io/g/devel/message/65643 Mute This Topic: https://groups.io/mt/77130071/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-