示例#1
0
/*
 * Store a pathname in the pathname store.
 */
char*
Pathstore_path(Pathstore *store, char *pathname, int discardDuplicateFiles)
{
	PathstoreElement *e;
	
	numstores++;
	
	if (discardDuplicateFiles) {
		if (SameFileIsInStore(store,pathname)) {
			numdups++;
			return NULL;
		}
	}
	
	e = malloc(sizeof(PathstoreElement));
	if (e == NULL) {
		return NULL;
	}
	
	e->pathname = strdup(pathname);
	if (e->pathname == NULL) {
		free(e);
		return NULL;
	}
	e->nextElement = store->elementList;
	store->elementList = e;
	
	return e->pathname;
	
}
示例#2
0
/*
 * Store a pathname in the pathname store.
 */
char*
Pathstore_path(Pathstore *store, char *pathname, int discardDuplicateFiles)
{
  PathstoreElement *e;

  numstores++;

  if (discardDuplicateFiles) {
    if (SameFileIsInStore(store,pathname)) {
      numdups++;
      return NULL;
    }
  }

  e = malloc(sizeof(PathstoreElement));
  if (e == NULL) {
    return NULL;
  }

  e->pathname = strdup(pathname);
  if (e->pathname == NULL) {
    free(e);
    return NULL;
  }
  e->nextElement = store->elementList;
  store->elementList = e;

  /* Hashing stuff */

  struct unixfilesystem *fs = (struct unixfilesystem *) (store->fshandle);
  int err = chksumfile_bypathname(fs, pathname, e->checksum);
  if (err < 0) {
    fprintf(stderr,"Can't checksum path %s\n", pathname);
    return 0;
  }

  return e->pathname;

}