/** \ingroup fslib * Get a file's attribute based on the 0-based index in the list (and not type, id pair). * @param a_fs_file File to get attributes from. * @param a_idx 0-based index of attribute to return. * @returns Pointer to attribute or NULL on error */ const TSK_FS_ATTR * tsk_fs_file_attr_get_idx(TSK_FS_FILE * a_fs_file, int a_idx) { if (tsk_fs_file_attr_check(a_fs_file, "tsk_fs_file_attr_get_idx")) return NULL; return tsk_fs_attrlist_get_idx(a_fs_file->meta->attr, a_idx); }
/** \ingroup fslib * Return the number of attributes in the file. * * @param a_fs_file File to return attribute count for * @returns number of attributes in file */ int tsk_fs_file_attr_getsize(TSK_FS_FILE * a_fs_file) { if (tsk_fs_file_attr_check(a_fs_file, "tsk_fs_file_attr_getsize")) return 0; return tsk_fs_attrlist_get_len(a_fs_file->meta->attr); }
/** \ingroup fslib * Return a specific type and id attribute for the file. * @param a_fs_file File to get data from * @param a_type Type of attribute to load * @param a_id Id of attribute to load * @param a_id_used Set to 1 if ID is actually set or 0 to use default * @returns NULL on error */ const TSK_FS_ATTR * tsk_fs_file_attr_get_type(TSK_FS_FILE * a_fs_file, TSK_FS_ATTR_TYPE_ENUM a_type, uint16_t a_id, uint8_t a_id_used) { if (tsk_fs_file_attr_check(a_fs_file, "tsk_fs_file_attr_get_type")) return NULL; if (a_id_used) return tsk_fs_attrlist_get_id(a_fs_file->meta->attr, a_type, a_id); else return tsk_fs_attrlist_get(a_fs_file->meta->attr, a_type); }
/** \ingroup fslib * Return the number of attributes in the file. * * @param a_fs_file File to return attribute count for * @returns number of attributes in file */ int tsk_fs_file_attr_getsize(TSK_FS_FILE * a_fs_file) { if (tsk_fs_file_attr_check(a_fs_file, "tsk_fs_file_attr_getsize")) { // @@@ Not sure if we should be ignoring this error or not... // Just added the reset because we were returning 0 with error codes set tsk_error_reset(); return 0; } return tsk_fs_attrlist_get_len(a_fs_file->meta->attr); }
/** \ingroup fslib * Return the default attribute for the file * @param a_fs_file File to get data from * @returns NULL on error */ const TSK_FS_ATTR * tsk_fs_file_attr_get(TSK_FS_FILE * a_fs_file) { TSK_FS_ATTR_TYPE_ENUM type; TSK_FS_INFO *fs; if (tsk_fs_file_attr_check(a_fs_file, "tsk_fs_file_attr_get")) return NULL; // since they did not give us a type, get the default for the file fs = a_fs_file->fs_info; type = fs->get_default_attr_type(a_fs_file); return tsk_fs_attrlist_get(a_fs_file->meta->attr, type); }
/** \ingroup fslib * Return a specific attribute by its ID for the file. * @param a_fs_file File to get data from * @param a_id Id of attribute to load * @returns NULL on error */ const TSK_FS_ATTR * tsk_fs_file_attr_get_id(TSK_FS_FILE * a_fs_file, uint16_t a_id) { int i, size; if (tsk_fs_file_attr_check(a_fs_file, "tsk_fs_file_attr_get_type")) return NULL; size = tsk_fs_file_attr_getsize(a_fs_file); for (i = 0; i < size; i++) { const TSK_FS_ATTR *fs_attr = tsk_fs_file_attr_get_idx(a_fs_file, i); if (fs_attr == NULL) return NULL; if (fs_attr->id == a_id) return fs_attr; } tsk_error_set_errno(TSK_ERR_FS_ATTR_NOTFOUND); tsk_error_set_errstr ("tsk_fs_attr_get_id: Attribute ID %d not found", a_id); return NULL; }