示例#1
0
rc_t CCCopyMake (CCCopy ** p, const KDirectory * in,  KDirectory * out, 
		  KDirectory * xml, bool force, KMD5SumFmt * md5,
		  CCFileFormat * ff, CCTree * tree, const char * path)
{
    rc_t rc;
    size_t pathlen;
    CCCopy * self;
    char relpath [4096];

    assert (in != NULL);
    assert (out != NULL);
    assert (xml != NULL);
    assert (path != NULL);

    rc = KDirectoryVResolvePath (in, false, relpath, sizeof relpath, path, NULL);
    if (rc != 0)
    {
	pLOGERR (klogErr, rc, "unable to resolve path $(P)", PLOG_S(P), path);
	return rc;
    }
    if ((relpath[0] == '.') && (relpath[1] == '.') && (relpath[2] == '/'))
    {
	rc = RC (rcExe, rcDirectory, rcResolving, rcPath, rcOutOfKDirectory);
	pLOGERR (klogErr, rc, "Path must resolve to current directory or subdirectories $(P)",
		 PLOG_S(P), relpath);
	return rc;
    }

    pathlen = strlen(relpath);
    self = malloc (sizeof (*self) - sizeof (*self->path) + pathlen + 1);
    if (self == NULL)
	rc = RC (rcExe, rcNoTarg, rcAllocating, rcMemory, rcExhausted);
    else
    {
	atomic32_set (&self->refcount, 1);
	KDirectoryAddRef (in);
	KDirectoryAddRef (out);
	KDirectoryAddRef (xml);
	KMD5SumFmtAddRef (md5);
	CCFileFormatAddRef (ff);
	self->in = in;
	self->out = out;
	self->xml = xml;
	self->force = force;
	self->md5 = md5;
	self->ff = ff;
	self->tree = tree;
	memcpy (self->path, relpath, pathlen+1);
	*p = self;
    }
    return rc;
}
示例#2
0
rc_t ProcessOneMake (ProcessOne ** ppo, const KDirectory * dir, KDirectory * xml,
		     const KFile * file, KMD5SumFmt *md5, CCFileFormat * ff,
		     const char * path)
{
    ProcessOne * self;
    rc_t rc = 0;
    size_t pathlen;

    PLOGMSG (klogDebug10, "ProcessOneMake $(f)", PLOG_S(f), path);
    /* legit seeming inputs? these could be replaced with RC returns */
    assert (ppo != NULL);
    assert (file != NULL);
    assert (path != NULL);

    /* allocate the object */
    pathlen = strlen (path);
    self = malloc (sizeof (*self) - sizeof(self->path) + pathlen + 1);
    if (self == NULL)
    {
	rc = RC (rcExe, rcNoTarg, rcAllocating, rcMemory, rcExhausted);
    }
    else
    {
	atomic32_set (&self->refcount, 1);
	KDirectoryAddRef (dir);
	KDirectoryAddRef (xml);
	KMD5SumFmtAddRef (md5);
	CCFileFormatAddRef (ff);
	KFileAddRef (file);
	self->dir = dir;
	self->xml = xml;
	self->md5 = md5;
	self->file = file;
	self->ff = ff;
	memcpy (self->path, path, pathlen);
	self->path[pathlen] = '\0';
	rc = 0;
    }
    *ppo = self;
    return rc;
}