char *concat_path_file(char *pdst,int size, const char *path, const char *filename)
{
char *lc;
if (!path)
{
path = "";
}
lc = last_char_is(path, '/');
while (*filename == '/')
{
filename++;
}
snprintf(pdst, size, "%s%s%s", path, (lc==NULL ? "/" : ""), filename);
return pdst;
}
static int IsFileExist(char *path)
{
if (!path)
{
return 0;
}
if (access(path, F_OK) == 0)
{
return 1;
}
else
{
return 0;
}
}
static int GetFileFromDir(DIR *dir, char *filename)
{
struct dirent *ent = NULL;
if (!dir || !filename)
{
return 0;
}
ent = readdir(dir);
if (!ent)
{
return 0;
}
strcpy(filename, ent->d_name);
return 1;
}
static int IsFileExistInDir(DIR *dir, char *fileName, int fileNameLen)
{
char buff[BUFFER_LEN_512];
if (!dir || !fileName)
{
return 0;
}
memset(buff, 0, BUFFER_LEN_512);
while (GetFileFromDir(dir, buff))
{
if ((int)strlen(buff) == fileNameLen)
{
if (0 == strncmp(buff, fileName, fileNameLen))
{
return 1;
}
}
}
return 0;