You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
997 B

#include "imageParserDataStructs.h"
CSTR buildMd5Path(CSTR base, CSTR md5, mode_t mode, CSTR user, CSTR group)
{
char tPath[1024];
char p1[3];
char p2[3];
char p3[3];
if (! fileExist(base))
{
return NULL;
}
memcpy(p1, md5, 2);
p1[2] = (char) 0;
sprintf(tPath, "%s/%s", base, p1);
if (! fileExist(tPath))
{
if (mkdir(tPath, mode) == -1)
{
return NULL;
}
if (user != NULL && group != NULL)
{
ch_chown(tPath, user, group);
}
};
memcpy(p2, md5 + 2, 2);
p2[2] = (char) 0;
sprintf(tPath, "%s/%s/%s", base, p1, p2);
if (! fileExist(tPath))
{
if (mkdir(tPath, mode) == -1)
{
return NULL;
}
if (user != NULL && group != NULL)
{
ch_chown(tPath, user, group);
}
};
memcpy(p3, md5 + 4, 2);
p3[2] = (char) 0;
sprintf(tPath, "%s/%s/%s/%s", base, p1, p2, p3);
if (! fileExist(tPath))
{
if (mkdir(tPath, mode) == -1)
{
return NULL;
}
if (user != NULL && group != NULL)
{
ch_chown(tPath, user, group);
}
};
return strdup(tPath);
}