|
42 | 42 |
|
43 | 43 | #include <dirent.h> |
44 | 44 | #include <errno.h> |
| 45 | +#include <limits.h> |
45 | 46 | #include <stdlib.h> |
46 | 47 | #include <stdio.h> |
47 | 48 | #include <time.h> |
@@ -1080,6 +1081,22 @@ static Obj FuncGAP_chdir(Obj self, Obj path) |
1080 | 1081 | return True; |
1081 | 1082 | } |
1082 | 1083 |
|
| 1084 | +/**************************************************************************** |
| 1085 | +** |
| 1086 | +*F FuncGAP_realpath( <self>, <path> ) . . . . TODO |
| 1087 | +*/ |
| 1088 | +static Obj FuncGAP_realpath(Obj self, Obj path) |
| 1089 | +{ |
| 1090 | + RequireStringRep(SELF_NAME, path); |
| 1091 | + char resolved_path[PATH_MAX]; |
| 1092 | + |
| 1093 | + if (NULL == realpath(CONST_CSTR_STRING(path), resolved_path)) { |
| 1094 | + SySetErrorNo(); |
| 1095 | + return Fail; |
| 1096 | + } |
| 1097 | + return MakeString(resolved_path); |
| 1098 | +} |
| 1099 | + |
1083 | 1100 |
|
1084 | 1101 | /**************************************************************************** |
1085 | 1102 | ** |
@@ -1716,6 +1733,7 @@ static StructGVarFunc GVarFuncs[] = { |
1716 | 1733 | GVAR_FUNC_1ARGS(IS_DIR, path), |
1717 | 1734 | GVAR_FUNC_0ARGS(GAP_getcwd), |
1718 | 1735 | GVAR_FUNC_1ARGS(GAP_chdir, path), |
| 1736 | + GVAR_FUNC_1ARGS(GAP_realpath, path), |
1719 | 1737 | GVAR_FUNC_0ARGS(LastSystemError), |
1720 | 1738 | GVAR_FUNC_1ARGS(IsExistingFile, filename), |
1721 | 1739 | GVAR_FUNC_1ARGS(IsReadableFile, filename), |
|
0 commit comments