Relative to absolute path

c++ builder

    Next

  • 1. Strange, I'm sure that i clicked send only once.........
    It's already the second time that it's happening to me, sorry about that, you can delete the extra message.... Ramy
  • 2. Save ClientDataset to XML format ?
    Hello, I want load data from XML files, use TXMLTransformProvider and TClientDataSet component , now i want add new filed in TClientDataSet for do this use Add/Calculated filed, but when i want save data to new xml file the calculated field don't add i use : ClientDataSet1->SaveToFile(dlg->FileName, dfXMLUTF8); and saved file is like load file ! Please help me how can do this ? Best Regards, M.T

Relative to absolute path

Postby PaoloItaly » Sat, 28 Oct 2006 23:17:58 GMT

I need to retrieve the absolute path of a file or directory
"..\..\pippo.txt" to "c:\somedir\someotherdir\pippo.txt"
somewhere in the standard C library may exist something i need.

Thanks in advance 



Re: Relative to absolute path

Postby JD » Sun, 29 Oct 2006 00:41:51 GMT




Most likely there is but I don't understand exactly what you
want. Please elaborate and be specific. Thanks.

~ JD


Re: Relative to absolute path

Postby PaoloItaly » Sun, 29 Oct 2006 01:05:59 GMT

> Most likely there is but I don't understand exactly what you
Directory structure:
c:\somedir00
  c:\somedir01
    c:\somedir02
  c:\somedir10
    pippo.txt

I've an ini file what describe the files contained in a project
ROOTDIR="c:\somedir00\somedir01\somedir02"
THEFILE0="..\..\somedir10\pippo.txt"

When the program load the ini file, set the current directory to 
"c:\somedir00\somedir01\somedir02" with chdir()
the file i've to load is "..\..\somedir10\pippo.txt" so in 
"c:\somedir0\somedir10\pippo.txt".

I need a function that given the path "..\..\somedir10\pippo.txt" retrieve 
the full path "c:\somedir00\somedir10\pippo.txt".
I've quite sure that the function exist but i can't remember it's name 
(SIGH!!!)

Thanks



Re: Relative to absolute path

Postby Chris Uzdavinis » Sun, 29 Oct 2006 01:09:02 GMT

"PaoloItaly" < XXXX@XXXXX.COM > writes:


Definately not in the standard library.  You may have some success
from the Boost.Filesystem library.  (See the function named
complete().)

-- 
Chris (TeamB);

Re: Relative to absolute path

Postby JD » Sun, 29 Oct 2006 01:26:51 GMT




You'll have to build your own.

If you were to manually do it using chdir(), you would change
the directory every time that you encounter a backslash. For
example, given "..\..\somedir10\pippo.txt"

    chdir( ".." );
    chdir( ".." );
    chdir( "somedir10" );

and you're there.

~ JD


Re: Relative to absolute path

Postby Palle Meinert » Sun, 29 Oct 2006 01:56:39 GMT

Since this is the vcl forum, you can use the VCL function ExpandFileName 
which does that

/Palle 



Re: Relative to absolute path

Postby JD » Sun, 29 Oct 2006 02:16:24 GMT




Hey! That works!

~ JD


Re: Relative to absolute path

Postby Hans Galema » Sun, 29 Oct 2006 04:46:09 GMT




Just add them:

   ROOTDIR + "\\" + THEFILE0

will give you:

   "c:\somedir00\somedir01\somedir02\..\..\somedir10\pippo.txt"

Which is the same as:

   "c:\somedir0\somedir10\pippo.txt".

Hans.

Re: Relative to absolute path

Postby PaoloItaly » Tue, 31 Oct 2006 17:01:14 GMT

Perfect!

and ExtractRelativePath does the rest of work...

Thanks

"Palle Meinert" < XXXX@XXXXX.COM > ha scritto nel messaggio 





Similar Threads:

1.How to chage Absolute url to relative url ,and relative url to absolute url

How to chage Absolute url to relative url ,and relative 
url to absolute url

2.absolute path to relative path conversion

3.Generated files with attributes and absolute/relative paths

I have an attributed ATL project (call it B) that I am 
building with Microsoft Visual C++ .NET (55537-640-3684941-
18356).  In the project I include the COM generated file 
A.h (from another ATL project A).  The compiler interprets 
this and injects the command "import A.idl" into the idl 
for B.  So far everything is okay.  The problem is that 
when I build project B in debug, it references A.idl using 
the absolute path.  When I build project B in release, it 
references A.idl using relative addressing.  The case for 
release is a problem because I have other projects that 
want to include B.idl, but are in a different relative 
directory.  My general question is if there is 
documentation on how the compiler decides to use relative 
or absolute paths for the files it inserts.  Failing that, 
does anyone know why switching from debug build to release 
build would change the choice of absolute or relative 
paths?  (I could find no project setting related to this 
issue.)  Thanks for any input.

4.Absolute and relative paths in VC6 dsp files...

Hi,
In VC6.0 when i insert an IDL file into my project from a folder that is
different from my current project folder, i was expecting it to remember the
name of the path as i inserted it. E.G. If my project is in
c:\vcprojects\myapp\component1\component1.dsp and an IDL file is in
c:\IDL\common.idl
The .dsp file does a relative path include. The result looks like this in my
DSP.
"..\..\..\idl\common.idl".
Is there any way to force the IDE to not do this and make it use only
"\idl\common.idl".

Hope i am clear..... Please let me know if you would like more information
for understanding the problem.

Thanks in advance for your time,
V


5.There are any Path or Directory function to convert an absolute path to a relative path?

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. relative path setting for include directory path

7. Excel and C# absolute and relative address's

8. how to get files and folders path as per system location absolute path



Return to c++ builder

 

Who is online

Users browsing this forum: No registered users and 67 guest