Skip to content

Instantly share code, notes, and snippets.

@Neradoc
Last active June 20, 2023 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neradoc/7074c75bb7a5b6b357fd3354ea125cd4 to your computer and use it in GitHub Desktop.
Save Neradoc/7074c75bb7a5b6b357fd3354ea125cd4 to your computer and use it in GitHub Desktop.
UOS compatibility for mpremote compatibility
import storage
from os import *
def get_mount_for(path):
path = path.rstrip("/")
if path[0] != "/":
path = os.getcwd() + "/" + path
while len(path) > 0:
try:
return storage.getmount(path)
except OSError:
pos = path.rfind("/")
path = path[:pos]
return None
def ilistdir(path):
mount = get_mount_for(path)
return mount.ilistdir(path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment