示例#1
0
int main(int argc,char *argv[])
{

    int i;
    char path[BUF_SIZE];
    if (argc < 2 || strcmp(argv[1],"--help") == 0)
    {
        usageErr("%s pathname1 pathname2 ...\n",argv[0]);
    }

    for (i = 1; i < argc; i++)
    {
        t_realpath(argv[i],path);
        printf("[%s] = %s\n",argv[i],path);
    }

    exit(EXIT_SUCCESS);
}
示例#2
0
static void test_link1(void)
{
	const char *old_dir, *npath = NULL, *error = NULL;
	test_assert(t_realpath_to(link1, "/", &npath, &error) == 0);
	test_assert_strcmp(npath, tmpdir);

	/* .../link1/link1/child */
	test_assert(t_realpath_to(t_strconcat(link1, "/link1/child", NULL),
				  "/", &npath, &error) == 0);
	test_assert_strcmp(npath, t_strconcat(tmpdir, "/child", NULL));

	/* relative link1/link1/child */
	if (t_get_working_dir(&old_dir, &error) < 0)
		i_fatal("t_get_working_dir() failed: %s", error);
	if (chdir(tmpdir) < 0)
		i_fatal("chdir(%s) failed: %m", tmpdir);
	test_assert(t_realpath(t_strconcat("link1", "/link1/child", NULL),
			       &npath, &error) == 0);
	if (chdir(old_dir) < 0)
		i_fatal("chdir(%s) failed: %m", old_dir);
}