Lines Matching +full:- +full:- +full:root
4 # SPDX-License-Identifier: GPL-2.0-only
114 # WARNING - this is not currently a drop in replacement since they return False
119 # WARNING - this is not currently a drop in replacement since they return False
157 def __is_path_below(self, file, root): argument
158 return (file + os.path.sep).startswith(root)
160 def __realpath_rel(self, start, rel_path, root, loop_cnt, assume_dir): argument
162 'root'; no part of 'start' below 'root' must contain symlinks. """
170 if len(start) >= len(root):
171 # do not follow '..' before root
178 root, loop_cnt, assume_dir)
180 assert(self.__is_path_below(start, root))
184 def __realpath(self, file, root, loop_cnt, assume_dir): argument
185 while self.islink(file) and len(file) >= len(root):
189 loop_cnt -= 1
194 assert(self.__is_path_below(tdir, root))
196 tdir = root
198 file = self.__realpath_rel(tdir, target, root, loop_cnt, assume_dir)
207 def realpath(self, file, root, use_physdir = True, loop_cnt = 100, assume_dir = False): argument
209 toplevel 'root' directory. When 'use_physdir' is set, all
215 root = os.path.normpath(root)
218 if not root.endswith(os.path.sep):
219 # letting root end with '/' makes some things easier
220 root = root + os.path.sep
222 if not self.__is_path_below(file, root):
223 raise OSError(errno.EINVAL, "file '%s' is not below root" % file)
227 file = self.__realpath_rel(root, file[(len(root) - 1):], root, loop_cnt, assume_dir)
229 file = self.__realpath(file, root, loop_cnt, assume_dir)[0]