Exemple #1
0
END_TEST

START_TEST(test_filename_dup)
{
  filename_t file;
  file.name = NULL;

  filename_t dup = filename_dup(&file);
  ck_assert_msg(NULL == dup.name, "Duplicating a filename that has not been"
    " properly created should return a filename_t with a NULL name");

  file = filename_create("frog");
  dup = filename_dup(&file);
  ck_assert_str_eq("frog", dup.name);
  ck_assert_str_eq(file.name, dup.name);
  filename_free(&file);
  filename_free(&dup);

  filename_t *fileptr = NULL;
  dup = filename_dup(fileptr);
  ck_assert_msg(NULL == dup.name, "Duplicating a filename_t * that is NULL"
    " shall return a filename_t whoes member variable name is NULL too.");
}
Exemple #2
0
static LocalFileInfo *CreateLocalFileInfo(const char *parentPath, const char *filename, int isdir, time_t mtime, size_t size, LocalFileInfo *parent)
{
	LocalFileInfo *info;
	info = (LocalFileInfo *)pcs_malloc(sizeof(LocalFileInfo));
	if (!parentPath || !parentPath[0]) {
		if (filename && filename[0])
			info->path = filename_dup(filename, &info->filename);
		else 
			info->filename = info->path = NULL;
	}
	else {
		if (filename && filename[0])
			info->path = combin_path(parentPath, filename, &info->filename);
		else
			info->path = path_dup(parentPath, &info->filename);
	}
	info->isdir = isdir;
	info->mtime = mtime;
	info->size = size;
	info->parent = parent;
	info->next = NULL;
	info->userdata = NULL;
	return info;
}