(self, dospath)
return path[root_len:]
Return the native dir path for a given BASIC dir path, relative to the root.
Return the native dir path for a given BASIC dir path, relative to the root.
Return the native dir path for a given BASIC dir path relative to the root .
def _get_native_reldir(self, dospath):
        """Return the native dir path for a given BASIC dir path, relative to the root."""
        if b'/' in dospath:
            # bad file number - this is what GW produces here
            raise error.BASICError(error.BAD_FILE_NUMBER)
        if not self._native_root:
            # this drive letter is not available (not mounted)
            raise error.BASICError(error.PATH_NOT_FOUND)
        # find starting directory
        if dospath and dospath[:1] == b'\\':
            # absolute path specified
            cwd = []
        else:
            cwd = self._native_cwd.split(os.sep)
        # parse internal .. and . and double slashes
        dospath = ntpath.normpath(dospath)
        # parse leading . and .. and double slashes in relative path
        # if at root, just drop leading dots (this is what GW-BASIC does at drive root)
        dospath_elements = dospath.split(b'\\')
        while dospath_elements and dospath_elements[0] in (b'', b'.', b'..'):
            if dospath_elements[0] == b'..':
                cwd = cwd[:-1]
            dospath_elements = dospath_elements[1:]
        # prepend drive root path to allow filename matching
        path = os.path.join(self._native_root, *cwd)
        root_len = len(self._native_root) + (self._native_root[-1:] != os.sep)
        # find the native matches for each step in the path
        for dos_elem in dospath_elements:
            # find a matching directory for every step in the path;
            native_elem = self._get_native_name(
                path, dos_elem, defext=b'', isdir=True, create=False
            )
            # append found name to path
            path = os.path.join(path, native_elem)
        # return relative path only
        return path[root_len:]
def _get_native_reldir ( self , dospath ) : if b'/' in dospath : # bad file number - this is what GW produces here raise error . BASICError ( error . BAD_FILE_NUMBER ) if not self . _native_root : # this drive letter is not available (not mounted) raise error . BASICError ( error . PATH_NOT_FOUND ) # find starting directory if dospath and dospath [ : 1 ] == b'\\' : # absolute path specified cwd = [ ] else : cwd = self . _native_cwd . split ( os . sep ) # parse internal .. and . and double slashes dospath = ntpath . normpath ( dospath ) # parse leading . and .. and double slashes in relative path # if at root, just drop leading dots (this is what GW-BASIC does at drive root) dospath_elements = dospath . split ( b'\\' ) while dospath_elements and dospath_elements [ 0 ] in ( b'' , b'.' , b'..' ) : if dospath_elements [ 0 ] == b'..' : cwd = cwd [ : - 1 ] dospath_elements = dospath_elements [ 1 : ] # prepend drive root path to allow filename matching path = os . path . join ( self . _native_root , * cwd ) root_len = len ( self . _native_root ) + ( self . _native_root [ - 1 : ] != os . sep ) # find the native matches for each step in the path for dos_elem in dospath_elements : # find a matching directory for every step in the path; native_elem = self . _get_native_name ( path , dos_elem , defext = b'' , isdir = True , create = False ) # append found name to path path = os . path . join ( path , native_elem ) # return relative path only return path [ root_len : ]