apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kevin seguin <seg...@motive.com>
Subject trying to get full path of file using apr_stat, apr_file_info_get
Date Fri, 22 Jun 2001 16:23:30 GMT
in the following code snippet, i'm trying to get the full path for a
given file name (in argv[1]) using apr_file_get_info() and apr_stat(). 
in looking at apr_file_info.h, it appears that apr_finfo_t.fname should
contain the full path for the file after calling these functions, but it
does not.  am i missing something, or is this just not working (i've
observed this behavior on both windows and redhat linux 7)?


    apr_pool_t *pool = 0;
    apr_file_t *thefile = 0;
    apr_finfo_t finfo1;
    apr_finfo_t finfo2;
    apr_int32_t flag = APR_READ;
    apr_int32_t want = APR_FINFO_NAME;
    const char* fname = 0;

    apr_pool_create(&pool, NULL);

    apr_file_open(&thefile, argv[1], flag, APR_UREAD, pool);
    apr_file_name_get(&fname, thefile);
    printf("fname = %s\n", fname);

    apr_file_info_get(&finfo1, want, thefile);
    printf("fname = %s\n", finfo1.fname);

    apr_stat(&finfo2, argv[1], want, pool);
    printf("fname = %s\n", finfo2.fname);

    char real[PATH_MAX];
    realpath(argv[1], real);
    printf("realname = %s\n", real);


View raw message