当前位置: 技术问答>linux和unix
请教下Ping()函数的用法
来源: 互联网 发布时间:2016-06-05
本文导语: static FILEPATH * findmatchfile(FILEDLGDATA *one, FILEPATH **cur ) { struct dirent *pDir; DIR *dir; struct stat ftype; char fullpath [PATH_MAX + NAME_MAX + 1]; FILEPATH ...
static FILEPATH * findmatchfile(FILEDLGDATA *one, FILEPATH **cur )
{
struct dirent *pDir;
DIR *dir;
struct stat ftype;
char fullpath [PATH_MAX + NAME_MAX + 1];
FILEPATH *head = NULL;
FILEPATH *temp = NULL;
dir = opendir (one->filepath);
while ( (pDir = readdir ( dir )) != NULL ) {
strncpy (fullpath, one->filepath, PATH_MAX);
if ( fullpath[ strlen(fullpath) - 1 ] != '/' )
strcat (fullpath, "/");
strcat (fullpath, pDir->d_name);
if (lstat (fullpath, &ftype) d_name) ) {
if( temp == NULL ) {
temp = (FILEPATH *) malloc(sizeof(FILEPATH));
temp->previous = NULL;
temp->next = NULL;
strcpy ( temp->name, fullpath);
head = temp;
}
else {
temp->next = (FILEPATH *) malloc(sizeof(FILEPATH));
temp->next->previous = temp;
temp->next->next = NULL;
temp = temp->next;
strcpy ( temp->name, fullpath);
}
/*indicate current file pointer*/
if ( !strcmp( pDir->d_name, one->filename ) )
*cur = temp;
}
}
closedir(dir);
return head;
}
此函数中Ping()的作用是什么?
{
struct dirent *pDir;
DIR *dir;
struct stat ftype;
char fullpath [PATH_MAX + NAME_MAX + 1];
FILEPATH *head = NULL;
FILEPATH *temp = NULL;
dir = opendir (one->filepath);
while ( (pDir = readdir ( dir )) != NULL ) {
strncpy (fullpath, one->filepath, PATH_MAX);
if ( fullpath[ strlen(fullpath) - 1 ] != '/' )
strcat (fullpath, "/");
strcat (fullpath, pDir->d_name);
if (lstat (fullpath, &ftype) d_name) ) {
if( temp == NULL ) {
temp = (FILEPATH *) malloc(sizeof(FILEPATH));
temp->previous = NULL;
temp->next = NULL;
strcpy ( temp->name, fullpath);
head = temp;
}
else {
temp->next = (FILEPATH *) malloc(sizeof(FILEPATH));
temp->next->previous = temp;
temp->next->next = NULL;
temp = temp->next;
strcpy ( temp->name, fullpath);
}
/*indicate current file pointer*/
if ( !strcmp( pDir->d_name, one->filename ) )
*cur = temp;
}
}
closedir(dir);
return head;
}
此函数中Ping()的作用是什么?
|
这个应该是自己写的函数,你自己再看看它具体的实现就知道了。