Skip to content

API_xar_add_folder

Rob Braun edited this page Feb 20, 2007 · 1 revision

Table of Contents

API Documentation

xar_file_t xar_add_folder(xar_t x, xar_file_t f, const char *name, struct stat *info)

Add a directory object to a xarchive

Description

xar_add_folder() adds a single directory object, represented by the passed file name and struct stat, to the xarchive represented by x.

Upon successful archival, xar_add_folder() will return a reference to the file handle (non-zero). On failure, NULL will be returned. If an error or warning occurs while adding the file to the xarchive, the callback registered via xar_register_errhandler() will be invoked.

Example

#include <xar/xar.h>

int main(int argc, char *argv[]) {
	xar_t x;
	struct stat sb;

	x = xar_open(argv[1], WRITE);
	if( x == NULL ) {
		fprintf(stderr, "Error opening xarchive: %s\n", argv[1]);
		exit(1);
	}

	memset(&sb, 0, sizeof(sb));
	sb.st_mode = S_IFDIR | S_IRWXU;

	if( xar_add(x, NULL, "mydir", &sb) == NULL ) {
		fprintf(stderr, "Error adding mydir to the xarchive\n");
	}

	...

	xar_close(x);
	
	...

}