MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / is_valid_abspath

Function is_valid_abspath

tools/cmdline.py:139–156  ·  view source on GitHub ↗
(path_name)

Source from the content-addressed store, hash-verified

137
138
139def is_valid_abspath(path_name):
140 # Any path that is underneath the emscripten repository root must be ok.
141 if utils.normalize_path(path_name).startswith(utils.normalize_path(utils.path_from_root())):
142 return True
143
144 def in_directory(root, child):
145 # make both path absolute
146 root = os.path.realpath(root)
147 child = os.path.realpath(child)
148
149 # return true, if the common prefix of both is equal to directory
150 # e.g. /a/b/c/d.rst and directory is /a/b, the common prefix is /a/b
151 return os.path.commonpath([root, child]) == root
152
153 for valid_abspath in options.valid_abspaths:
154 if in_directory(valid_abspath, path_name):
155 return True
156 return False
157
158
159def is_dash_s_for_emcc(args, i):

Callers 1

parse_argsFunction · 0.85

Calls 1

in_directoryFunction · 0.85

Tested by

no test coverage detected