1#
2# Copyright 2017 - The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import posixpath
17
18
19def JoinTargetPath(path, *paths):
20    """Concatenates paths and inserts target path separators between them.
21
22    Args:
23        path: string, the first path to be concatenated.
24        *paths: tuple of strings, the other paths to be concatenated.
25
26    Returns:
27        string, the concatenated path.
28    """
29    return posixpath.join(path, *paths)
30
31
32def TargetBaseName(path):
33    """Returns the base name of the path on target device.
34
35    Args:
36        path: string, the path on target device.
37
38    Returns:
39        string, the base name.
40    """
41    return posixpath.basename(path)
42
43
44def TargetDirName(path):
45    """Returns the directory name of the path on target device.
46
47    Args:
48        path: string, the path on target device.
49
50    Returns:
51        string, the directory name.
52    """
53    return posixpath.dirname(path)
54
55
56def TargetNormPath(path):
57    """Removes redundant separators and resolves relative path.
58
59    Args:
60        path: string, the path on target device.
61
62    Returns:
63        string, the normalized path.
64    """
65    return posixpath.normpath(path)
66
67