Is there a function to convert relative file names into absolute ones?
Best
Ari
Relative and absolute file names
Re: Relative and absolute file names
Are you wanting to canonicalize a path? For example convert "C:\abs\..\abc\file.txt" to "C:\abc\file.txt"? Just curious what is your use need for this?
Re: Relative and absolute file names
Hi Aaron,
I have a need to display the complete (canocalized) name of the directory where the reports will be stored.
This directory is informd in the program as a relative path, such as
dirname = ..\..\.._50_Reports
and this name is concatenated with the filename to store the specific report.
When I show the complete name of the report (including the directory name) I would like to show it as a its proper name, not the relative name.
I know this is not your priority (mine either), it was just to improve the software-user communication.
Best
Ari
I have a need to display the complete (canocalized) name of the directory where the reports will be stored.
This directory is informd in the program as a relative path, such as
dirname = ..\..\.._50_Reports
and this name is concatenated with the filename to store the specific report.
When I show the complete name of the report (including the directory name) I would like to show it as a its proper name, not the relative name.
I know this is not your priority (mine either), it was just to improve the software-user communication.
Best
Ari
Best
Ari
Ari
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Relative and absolute file names
You could write a helper function that uses the filename function to get the full name:
function string GetAbsoluteFilename(string relative_filename)
file temp_file;
setfile(temp_file, relative_filename);
GetAbsoluteFilename = filename(temp_file);
close(temp_file);
end;
// ...
errmsg("%s", GetAbsoluteFilename("..\MyFile.txt"));
That assumes that the file exists.file temp_file;
setfile(temp_file, relative_filename);
GetAbsoluteFilename = filename(temp_file);
close(temp_file);
end;
// ...
errmsg("%s", GetAbsoluteFilename("..\MyFile.txt"));
Re: Relative and absolute file names
Great, Greg.
Thank you, that´s what I needed.
Best
Ari
Thank you, that´s what I needed.
Best
Ari
Best
Ari
Ari