How to get the absolute path for a given relative path programmatically in Linux?

后端 未结 7 1829
轻奢々
轻奢々 2020-12-05 07:33

How to get the absolute path for a given relative path programmatically in Linux?

Incase of Windows we have the _fullpath() API. In other words, I mean

7条回答
  •  孤城傲影
    2020-12-05 08:05

    // For C++ with Gnome Gtkmm3 libraries
    #include 
    #include 
    
      string PathRel2Abs(string relpath) {
      Glib::RefPtr file = Gio::File::create_for_path(relpath);
      return file->get_path();
    }
    

提交回复
热议问题