source: rtems-tools/linkers/rld-path.h @ 40fd7a0

4.104.115
Last change on this file since 40fd7a0 was 40fd7a0, checked in by Chris Johns <chrisj@…>, on 09/01/14 at 03:26:47

rld: Split the file into a path module for path specific functions.

This allows resued for other parts of the system not dependent on
objcet files or archives.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2011-2014, Chris Johns <chrisj@rtems.org>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16/**
17 * @file
18 *
19 * @ingroup rtems-ld
20 *
21 * @brief RTEMS Linker Path to help manage paths.
22 *
23 */
24
25#if !defined (_RLD_PATH_H_)
26#define _RLD_PATH_H_
27
28#include <list>
29#include <map>
30#include <string>
31#include <vector>
32
33#include <rld.h>
34
35namespace rld
36{
37  namespace path
38  {
39    /**
40     * Container of file paths.
41     */
42    typedef std::vector < std::string > paths;
43
44    /**
45     * Return the basename of the file name.
46     *
47     * @param name The full file name.
48     * @return std::string The basename of the file.
49     */
50    std::string basename (const std::string& name);
51
52    /**
53     * Return the dirname of the file name.
54     *
55     * @param name The full file name.
56     * @return std::string The dirname of the file.
57     */
58    std::string dirname (const std::string& name);
59
60    /**
61     * Return the extension of the file name.
62     *
63     * @param name The full file name.
64     * @return std::string The extension of the file.
65     */
66    std::string extension (const std::string& name);
67
68    /**
69     * Split a path from a string with a delimiter to the path container. Add
70     * only the paths that exist and ignore those that do not.
71     *
72     * @param path The paths as a single string delimited by the path
73     *             separator.
74     * @param paths The split path paths.
75     */
76    void path_split (const std::string& path,
77                     paths&             paths);
78
79    /**
80     * Make a path by joining the parts with required separator.
81     *
82     * @param path_ The path component to be joined.
83     * @param file_ The file name to add to the path.
84     * @param joined The joined path and file name with a path separator.
85     */
86    void path_join (const std::string& path_,
87                    const std::string& file_,
88                    std::string&       joined);
89
90    /**
91     * Check the path is a file using a stat call.
92     *
93     * @param path The path to check.
94     * @retval true The path is valid.
95     * @retval false The path is not valid.
96     */
97    bool check_file (const std::string& path);
98
99    /**
100     * Check if the path is a directory.
101     *
102     * @param path The path to check.
103     * @retval false The path is not a directory.
104     * @retval true The path is a directory.
105     */
106    bool check_directory (const std::string& path);
107
108    /**
109     * Find the file given a container of paths and file names.
110     *
111     * @param path The path of the file if found else empty.
112     * @param name The name of the file to search for.
113     * @param search_paths The container of paths to search.
114     */
115    void find_file (std::string&       path,
116                    const std::string& name,
117                    paths&             search_paths);
118
119  }
120}
121
122#endif
Note: See TracBrowser for help on using the repository browser.