Changeset b249516 in rtems-tools


Ignore:
Timestamp:
Mar 29, 2015, 7:06:00 AM (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, master
Children:
e98d5fa
Parents:
5032d71
Message:

rtemstoolkit: Add support to return the system path split as paths.

Seacch the path for the program name if not found and set it as
an absolute path. This allow the prefix to be found.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • linkers/rtems-tld.cpp

    r5032d71 rb249516  
    14981498                         const std::string& path)
    14991499    {
    1500       std::string sp = get_prefix ();
     1500      std::string sp = rld::get_prefix ();
    15011501
    15021502      rld::path::path_join (sp, "share", sp);
  • rtemstoolkit/rld-path.cpp

    r5032d71 rb249516  
    215215      }
    216216    }
     217
     218    void
     219    get_system_path (paths& paths)
     220    {
     221      const char* path = ::getenv ("PATH");
     222      strings     ps;
     223      rld::split (ps, path, RLD_PATHSTR_SEPARATOR);
     224      if (ps.size ())
     225      {
     226        for (strings::iterator psi = ps.begin ();
     227             psi != ps.end ();
     228             ++psi)
     229        {
     230          if (check_directory (*psi))
     231            paths.push_back (*psi);
     232        }
     233      }
     234    }
    217235  }
    218236}
  • rtemstoolkit/rld-path.h

    r5032d71 rb249516  
    145145    void unlink (const std::string& path, bool not_present_error = false);
    146146
     147    /**
     148     * Return the system path as a set of strings.
     149     *
     150     * @param paths The split path paths.
     151     */
     152    void get_system_path (paths& paths);
    147153  }
    148154}
  • rtemstoolkit/rld.cpp

    r5032d71 rb249516  
    236236  set_progname (const std::string& progname_)
    237237  {
    238     progname = rld::path::path_abs (progname_);
     238    if (rld::path::check_file (progname_))
     239      progname = rld::path::path_abs (progname_);
     240    else
     241    {
     242      rld::path::paths paths;
     243      rld::path::get_system_path (paths);
     244      for (rld::path::paths::const_iterator path = paths.begin ();
     245           path != paths.end ();
     246           ++path)
     247      {
     248        std::string pp;
     249        rld::path::path_join (*path, progname_, pp);
     250        if (rld::path::check_file (pp))
     251        {
     252          progname = rld::path::path_abs (pp);
     253          break;
     254        }
     255      }
     256    }
    239257  }
    240258
     
    263281    if (rld::path::basename (pp) == "bin")
    264282      return rld::path::dirname (pp);
    265     return "";
     283    return pp;
    266284  }
    267285
Note: See TracChangeset for help on using the changeset viewer.