473,411 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Relative path to absolute

4
Hi there.

I'm writing a program under Linux. I need a function that convert relative path to absolute (or full path). Under Windows, I have a GetFullPathName function in WinAPI. But now, I need function for Linux (glibc may be).

Can someone help me?

P.S. Googling, googling... nothing found ;-(
Jan 6 '09 #1
2 19254
ashitpro
542 Expert 512MB
yes....
you are after "realpath"...
Expand|Select|Wrap|Line Numbers
  1. #include <limits.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. int main()
  5. {
  6.         char resolved_path[100];
  7.         realpath("../../", resolved_path);
  8.         printf("\n%s\n",resolved_path);
  9.         return 0;
  10. }
  11.  
Jan 6 '09 #2
mac11
256 100+
Another option, if you're using c++ anyway, is to use boost::filesystem. It provides portable file system stl-like objects.

Boost C++ Libraries
Jan 6 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Nick K. | last post by:
I recently began maintenance work on a production web server that is located in the root directory of a web server. I moved this into a sub web on my local web server in order to do work on it. I...
4
by: Richard | last post by:
We are distributing a VS2003 solution to our customers that includes a .NET assembly (dll file) and a sample project for how to use the dll. The customer can then customize the sample or add a new...
7
by: Rizaan Jappie | last post by:
is it possible to get the relative path based on a absolute path in c#? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
0
by: Ffelagund | last post by:
There are any Path or Directory function to convert an absolute path to a relative path using a choiced directory as base to calculate the origin of the relative path?
6
by: openleren | last post by:
Hi all, how can I use a relative path in my web.config file for an Access db?: Instead of using <configuration> <appSettings> <add key="conAccess" value="microsoft.jet.oledb.4.0;data...
4
by: Boni | last post by:
Is there something already done to get absolute path from relative path, and relative path from absolute path: Example: BasePath="c:\a\b\c" RelativePath="..\e\f\g\..\m"...
0
by: Nick | last post by:
Hi, I need to strong name my application and thus have to specify the sn key path in the <Assembly: AssemblyKeyFile("strongNameKey.snk")> parameter. Observations: If I specify the hardcoded...
19
by: Jerry M. Gartner | last post by:
Greetings: What is the best way to resolve paths within a document regardless of what path it is opened under? For example: I have x.php and it contains <img src="images...">, (amongst other...
2
by: =?Utf-8?B?ZmFpcnl2b2ljZQ==?= | last post by:
hi, i just want to know when i new a Uri instance using the UriKind.Relative para in construtor, where is the root path, for example, a local file Uri u=new Uri("a.txt",UriKind.Relative); then...
1
by: ahmed786 | last post by:
Hello , I am a new in PHP.I have a task to resolve realtive path to absolute path. for example : ../default/test.png -> /image/default/test.png I have done it with string replace...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.