Logo Search packages:      
Sourcecode: rapple version File versions  Download package

int rpl_fs_resolve_paths ( rpl_c_str_t  filename,
rpl_c_str_t  basedir,
rpl_str_t *  rel_dir,
rpl_str_t *  file 

Extracts the relative (to a base directory) path and filename from an absolute filename. This convenience function addresses a need to resolve filenames that frequently arises in processing modules. In order to extract the relative directory a check that the basedir matches the start of the absolute filename is made.

filename absolute filename from which paths are to be extracted.
basedir the directory relative to which the relative directory is formed.
rel_dir return pointer to relative directory
file return pointer to filename
1 if the path and filename cannot be extracted (basedir failes to match) 0 otherwise.

Definition at line 468 of file fsutil.c.

References rpl_log_error(), rpl_message_get(), and rpl_str_rsplit().

Referenced by rpl_mod_db_process(), rpl_mod_index_process(), rpl_mod_init_process(), rpl_mod_link_process(), rpl_mod_parse_process(), rpl_mod_tidy_process(), and rpl_mod_xslt_process().

      rpl_str_t a_rel_dir, a_file;
      char *rfp;

      assert((filename != NULL) && (basedir != NULL));

      if(strcmp(filename, basedir) == 0)
            *rel_dir = "";
            *file = "";
      } else {
            rfp = strdup(filename);
            if(strstr(rfp, basedir) == NULL)
                  /* str match check to validate the filename argument */
                  rpl_log_error(rpl_message_get("REG_INVALID_PATH", filename, RPL_EOM));
                  *rel_dir = RPL_STR_NUL;
                  *file = RPL_STR_NUL;
                  return 1;
            /* make sure to step over the trailing "/" in the base pathname */
            rfp += strlen(basedir) + 1;
            rpl_str_rsplit(rfp, '/', &a_rel_dir, &a_file);
            *rel_dir = a_rel_dir;
            *file = a_file;
      return 0;

Generated by  Doxygen 1.6.0   Back to index