Commit fd7ae28a authored by Benoît Minisini's avatar Benoît Minisini

File.RealPath() is a new statis method that returns the the canonicalized...

File.RealPath() is a new statis method that returns the the canonicalized absolute pathname of path, with no symbolic links inside.

[INTERPRETER]
* NEW: File.RealPath() is a new statis method that returns the the canonicalized absolute pathname of path, with no symbolic links inside.
parent 7c808bbb
......@@ -730,6 +730,22 @@ BEGIN_METHOD(File_IsHidden, GB_STRING path)
END_METHOD
BEGIN_METHOD(File_RealPath, GB_STRING path)
char *path = STRING_conv_file_name(STRING(path), LENGTH(path));
char *rpath = NULL;
if (!FILE_is_relative(path))
{
rpath = realpath(path, NULL);
path = rpath;
}
GB_ReturnNewZeroString(path);
if (rpath) free(rpath);
END_METHOD
//---------------------------------------------------------------------------
BEGIN_PROPERTY(Stream_Handle)
......@@ -1114,6 +1130,8 @@ GB_DESC FileDesc[] =
GB_STATIC_METHOD("Load", "s", File_Load, "(FileName)s"),
GB_STATIC_METHOD("Save", NULL, File_Save, "(FileName)s(Data)s"),
GB_STATIC_METHOD("RealPath", "s", File_RealPath, "(Path)s"),
GB_EVENT("Read", NULL, NULL, &EVENT_Read),
GB_EVENT("Write", NULL, NULL, &EVENT_Write),
GB_EVENT("Resize", NULL, NULL, &EVENT_Resize),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment