• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ readdir_r函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中readdir_r函数的典型用法代码示例。如果您正苦于以下问题:C++ readdir_r函数的具体用法?C++ readdir_r怎么用?C++ readdir_r使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了readdir_r函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: psy_enum_devs

static int psy_enum_devs(void)
{
#ifdef WIN32
	int fd, i, ret = 0;
	char name[MAX_FNAME_SZ];

	for (i = 0; i < MAX_PSY_DEVS; i++) {
		snprintf(name, MAX_FNAME_SZ, "/dev/power_supply%d", i);
		fd = open(name, O_RDWR);
		if (fd < 0)
			continue;
		ret = psy_add_dev(fd);
		if (ret) {
			close(fd);
			break;
		}
	}
	return ret;
#else
	DIR *dir;
	struct dirent *entry = NULL;

	dir = opendir("/sys/class/power_supply");
	if (dir == NULL)
		return errno;
	for (entry = readdir(dir); entry != NULL;) {
		if (entry->d_name[0] != '.') {
			if (psy_add_dev(entry->d_name)) {
				closedir(dir);
				return errno;
			}
		}
		if (readdir_r(dir, entry, &entry)) {
			closedir(dir);
			return errno;
		}
	}
	closedir(dir);
	return 0;
#endif
}
开发者ID:hiro-sakamoto,项目名称:linux_emu,代码行数:41,代码来源:psy_enum.c


示例2: opendir

int VolumeManager::unmountAllAsecsInDir(const char *directory) {
    DIR *d = opendir(directory);
    int rc = 0;

    if (!d) {
        SLOGE("Could not open asec dir %s", directory);
        return -1;
    }

    size_t dirent_len = offsetof(struct dirent, d_name) +
            fpathconf(dirfd(d), _PC_NAME_MAX) + 1;

    struct dirent *dent = (struct dirent *) malloc(dirent_len);
    if (dent == NULL) {
        SLOGE("Failed to allocate memory for asec dir");
        return -1;
    }

    struct dirent *result;
    while (!readdir_r(d, dent, &result) && result != NULL) {
        if (dent->d_name[0] == '.')
            continue;
        if (dent->d_type != DT_REG)
            continue;
        size_t name_len = strlen(dent->d_name);
        if (name_len > 5 && name_len < (ID_BUF_LEN + ASEC_SUFFIX_LEN - 1) &&
                !strcmp(&dent->d_name[name_len - 5], ASEC_SUFFIX)) {
            char id[ID_BUF_LEN];
            strlcpy(id, dent->d_name, name_len - 4);
            if (unmountAsec(id, true)) {
                /* Register the error, but try to unmount more asecs */
                rc = -1;
            }
        }
    }
    closedir(d);

    free(dent);

    return rc;
}
开发者ID:Android4SAM,项目名称:platform_system_vold,代码行数:41,代码来源:VolumeManager.cpp


示例3: listsubdir

bool listsubdir(const char *dir, vector<char *> &subdirs)
{
    #if defined(WIN32)
    defformatstring(pathname)("%s\\*", dir);
    WIN32_FIND_DATA FindFileData;
    HANDLE Find = FindFirstFile(path(pathname), &FindFileData);
    if(Find != INVALID_HANDLE_VALUE)
    {
        do {
            if((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && FindFileData.cFileName[0] != '.') subdirs.add(newstring(FindFileData.cFileName));
        } while(FindNextFile(Find, &FindFileData));
        FindClose(Find);
        return true;
    }
    #else
    string pathname;
    copystring(pathname, dir);
    DIR *d = opendir(path(pathname));
    if(d)
    {
        struct dirent *de, b;
        while(!readdir_r(d, &b, &de) && de != NULL)
        {
        #ifdef _DIRENT_HAVE_D_TYPE
            if(de->d_type == DT_DIR && de->d_name[0] != '.') subdirs.add(newstring(de->d_name));
            else if(de->d_type == DT_UNKNOWN && de->d_name[0] != '.')
        #endif
            {
                struct stat s;
                int dl = (int)strlen(pathname);
                concatformatstring(pathname, "/%s", de->d_name);
                if(!lstat(pathname, &s) && S_ISDIR(s.st_mode) && de->d_name[0] != '.') subdirs.add(newstring(de->d_name));
                pathname[dl] = '\0';
            }
        }
        closedir(d);
        return true;
    }
    #endif
    else return false;
}
开发者ID:ac-stef,项目名称:AC,代码行数:41,代码来源:stream.cpp


示例4: scandir

void scandir(const std::string& path,
             const std::string& extension,
             std::vector<std::string>* files) {
  files->clear();

  std::string search_path = path.empty() ? "." : path;
  DIR* dir = opendir(ResolvePath(search_path).c_str());
  if (!dir) return;

  struct dirent entry;
  struct dirent* result;

  while (readdir_r(dir, &entry, &result) == 0) {
    if (result == NULL) break;
    if (mats::ends_with(entry.d_name, extension)) {
      files->emplace_back(entry.d_name);
    }
  }

  closedir(dir);
}
开发者ID:psalvaggio,项目名称:multaptelescope,代码行数:21,代码来源:filesystem.cpp


示例5: synthesize_all

static void synthesize_all(void)
{
	DIR *proc;
	struct dirent dirent, *next;

	proc = opendir("/proc");

	while (!readdir_r(proc, &dirent, &next) && next) {
		char *end;
		pid_t pid, tgid;

		pid = strtol(dirent.d_name, &end, 10);
		if (*end) /* only interested in proper numerical dirents */
			continue;

		tgid = pid_synthesize_comm_event(pid, 1);
		pid_synthesize_mmap_samples(pid, tgid);
	}

	closedir(proc);
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:21,代码来源:builtin-record.c


示例6: local_readdir_r

static int local_readdir_r(FsContext *ctx, V9fsFidOpenState *fs,
                           struct dirent *entry,
                           struct dirent **result)
{
    int ret;

again:
    ret = readdir_r(fs->dir, entry, result);
    if (ctx->export_flags & V9FS_SM_MAPPED) {
        entry->d_type = DT_UNKNOWN;
    }
    else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
        if (!ret && *result != NULL &&
            !strcmp(entry->d_name, VIRTFS_META_DIR)) {
            /* skp the meta data directory */
            goto again;
        }
        entry->d_type = DT_UNKNOWN;
    }
    return ret;
}
开发者ID:philippegabriel,项目名称:qemu,代码行数:21,代码来源:virtio-9p-local.c


示例7: opendir

void CommandListener::AsecCmd::listAsecsInDirectory(SocketClient *cli, const char *directory) {
    DIR *d = opendir(directory);

    if (!d) {
        cli->sendMsg(ResponseCode::OperationFailed, "Failed to open asec dir", true);
        return;
    }

    size_t dirent_len = offsetof(struct dirent, d_name) +
            fpathconf(dirfd(d), _PC_NAME_MAX) + 1;

    struct dirent *dent = (struct dirent *) malloc(dirent_len);
    if (dent == NULL) {
        cli->sendMsg(ResponseCode::OperationFailed, "Failed to allocate memory", true);
        return;
    }

    struct dirent *result;

    while (!readdir_r(d, dent, &result) && result != NULL) {
        if (dent->d_name[0] == '.')
            continue;
        // For whatever reason, the exFAT fuse driver reports DT_UNKNOWN for
        // the .asec files, so we'll have to allow that to make external apps
        // work properly.
        if (dent->d_type != DT_REG && dent->d_type != DT_UNKNOWN)
            continue;
        size_t name_len = strlen(dent->d_name);
        if (name_len > 5 && name_len < 260 &&
                !strcmp(&dent->d_name[name_len - 5], ".asec")) {
            char id[255];
            memset(id, 0, sizeof(id));
            strlcpy(id, dent->d_name, name_len - 4);
            cli->sendMsg(ResponseCode::AsecListResult, id, false);
        }
    }
    closedir(d);

    free(dent);
}
开发者ID:optimumpr,项目名称:android_system_vold,代码行数:40,代码来源:CommandListener.cpp


示例8: removeDirectory

void removeDirectory(const Path &path)
{
    DIR *d = opendir(path.constData());
    size_t path_len = path.size();
    char buf[PATH_MAX];
    dirent *dbuf = reinterpret_cast<dirent*>(buf);

    if (d) {
        dirent *p;

        while (!readdir_r(d, dbuf, &p) && p) {
            char *buf;
            size_t len;

            /* Skip the names "." and ".." as we don't want to recurse on them. */
            if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, "..")) {
                continue;
            }

            len = path_len + strlen(p->d_name) + 2;
            buf = static_cast<char*>(malloc(len));

            if (buf) {
                struct stat statbuf;
                snprintf(buf, len, "%s/%s", path.constData(), p->d_name);
                if (!stat(buf, &statbuf)) {
                    if (S_ISDIR(statbuf.st_mode)) {
                        removeDirectory(buf);
                    } else {
                        unlink(buf);
                    }
                }

                free(buf);
            }
        }
        closedir(d);
    }
    rmdir(path.constData());
}
开发者ID:farva,项目名称:rct,代码行数:40,代码来源:Rct.cpp


示例9: CopyDir

// Create directory and copy contents (does not overwrite existing files)
void CopyDir(const std::string &source_path, const std::string &dest_path)
{
#ifndef _WIN32
    if (source_path == dest_path) return;
    if (!File::Exists(source_path)) return;
    if (!File::Exists(dest_path)) File::CreateFullPath(dest_path);

    struct dirent_large {
        struct dirent entry;
        char padding[FILENAME_MAX+1];
    };
    struct dirent_large diren;
    struct dirent *result = NULL;
    DIR *dirp = opendir(source_path.c_str());
    if (!dirp) return;

    while (!readdir_r(dirp, (dirent*) &diren, &result) && result)
    {
        const std::string virtualName(result->d_name);
        // check for "." and ".."
        if (((virtualName[0] == '.') && (virtualName[1] == '\0')) ||
                ((virtualName[0] == '.') && (virtualName[1] == '.') &&
                 (virtualName[2] == '\0')))
            continue;

        std::string source, dest;
        source = source_path + virtualName;
        dest = dest_path + virtualName;
        if (IsDirectory(source))
        {
            source += '/';
            dest += '/';
            if (!File::Exists(dest)) File::CreateFullPath(dest);
            CopyDir(source, dest);
        }
        else if (!File::Exists(dest)) File::Copy(source, dest);
    }
    closedir(dirp);
#endif
}
开发者ID:Summeli,项目名称:ppsspp,代码行数:41,代码来源:FileUtil.cpp


示例10: listFiles

static void             /* List all files in directory 'dirpath' */
listFiles(const char *dirpath)
{
    DIR *dirp;
    struct dirent entry, *result;
    Boolean isCurrent;          /* True if 'dirpath' is "." */

    isCurrent = strcmp(dirpath, ".") == 0;

    dirp = opendir(dirpath);
    if (dirp  == NULL) {
        errMsg("opendir failed on '%s'", dirpath);
        return;
    }

    /* For each entry in this directory, print directory + filename */

    for (;;) {
        errno = 0;              /* To distinguish error from end-of-directory */
        if (readdir_r(dirp, &entry, &result) == -1) {
		errMsg("readdir_r");
		continue;
	}
        if (result == NULL)
            break;

        if (strcmp(entry.d_name, ".") == 0 || strcmp(entry.d_name, "..") == 0)
            continue;           /* Skip . and .. */

        if (!isCurrent)
            printf("%s/", dirpath);
        printf("%s\n", entry.d_name);
    }

    if (errno != 0)
        errExit("readdir");

    if (closedir(dirp) == -1)
        errMsg("closedir");
}
开发者ID:tcharding,项目名称:self_learning,代码行数:40,代码来源:list_files.c


示例11: perf_event__synthesize_threads

int perf_event__synthesize_threads(perf_event__handler_t process,
                                   struct perf_session *session)
{
    DIR *proc;
    struct dirent dirent, *next;
    union perf_event *comm_event, *mmap_event;
    int err = -1;

    comm_event = malloc(sizeof(comm_event->comm) + session->id_hdr_size);
    if (comm_event == NULL)
        goto out;

    mmap_event = malloc(sizeof(mmap_event->mmap) + session->id_hdr_size);
    if (mmap_event == NULL)
        goto out_free_comm;

    proc = opendir("/proc");
    if (proc == NULL)
        goto out_free_mmap;

    while (!readdir_r(proc, &dirent, &next) && next) {
        char *end;
        pid_t pid = strtol(dirent.d_name, &end, 10);

        if (*end) /* only interested in proper numerical dirents */
            continue;

        __event__synthesize_thread(comm_event, mmap_event, pid,
                                   process, session);
    }

    closedir(proc);
    err = 0;
out_free_mmap:
    free(mmap_event);
out_free_comm:
    free(comm_event);
out:
    return err;
}
开发者ID:AbheekG,项目名称:XIA-for-Linux,代码行数:40,代码来源:event.c


示例12: arc_dir

value arc_dir(arc *c, value dirname)
{
  char *utf_filename;
  DIR *dirp;
  int en;
  value dirlist;
  struct dirent *entry, *result;
  int delen;

  TYPECHECK(dirname, T_STRING);
  utf_filename = alloca(FIX2INT(arc_strutflen(c, dirname)) + 1);
  arc_str2cstr(c, dirname, utf_filename);
  dirp = opendir(utf_filename);
  if (dirp == NULL) {
    en = errno;
    arc_err_cstrfmt(c, "dir: cannot open directory \"%s\", (%s; errno=%d)", utf_filename, strerror(en), en);
    return(CNIL);
  }
  dirlist = CNIL;
  delen = offsetof(struct dirent, d_name)
    + pathconf(utf_filename, _PC_NAME_MAX) + 1;
  entry = (struct dirent *)alloca(delen);
  for (;;) {
    if (readdir_r(dirp, entry, &result) != 0) {
      /* error */
      en = errno;
      arc_err_cstrfmt(c, "dir: error reading directory \"%s\", (%s; errno=%d)", utf_filename, strerror(en), en);
      return(CNIL);
    }
    /* end of list */
    if (result == NULL)
      break;
    /* ignore the . and .. directories */
    if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
      continue;
    dirlist = cons(c, arc_mkstringc(c, entry->d_name), dirlist);
  }
  closedir(dirp);
  return(dirlist);
}
开发者ID:GrimDerp,项目名称:arcueid,代码行数:40,代码来源:dirops.c


示例13: opendir

ssize_t native_dir::read_all_files(std::vector<std::string> &files) const
{
	DIR *d = opendir(name.c_str());
	if (d == NULL) {
		fprintf(stderr, "can't open %s: %s\n", name.c_str(),
				strerror(errno));
		return -1;
	}
	struct dirent *entryp;
	long path_limit = pathconf(name.c_str(), _PC_NAME_MAX);
	if (path_limit < 0) {
		perror("pathconf");
		path_limit = sizeof(entryp->d_name);
	}
	int len = offsetof(struct dirent, d_name) + path_limit + 1;
	entryp = (struct dirent *) malloc(len);
	struct dirent *result;
	ssize_t num = 0;
	while (true) {
		int ret = readdir_r(d, entryp, &result);
		if (ret != 0) {
			fprintf(stderr, "can't read dir %s: %s\n", name.c_str(),
					strerror(ret));
			num = -1;
			break;
		}
		// End of the directory stream.
		if (result == NULL)
			break;

		assert(result == entryp);
		std::string file = entryp->d_name;
		if (file != "." && file != "..")
			files.push_back(file);
		num++;
	}
	free(entryp);
	closedir(d);
	return num;
}
开发者ID:zheng-da,项目名称:FlashX,代码行数:40,代码来源:native_file.cpp


示例14: ReadDirR

int32_t ReadDirR(DIR* dir, void* buffer, int32_t bufferSize, DirectoryEntry* outputEntry)
{
    assert(buffer != nullptr);
    assert(dir != nullptr);
    assert(outputEntry != nullptr);

    if (bufferSize < sizeof(dirent))
    {
        assert(!"Buffer size too small; use GetDirentSize to get required buffer size");
        return ERANGE;
    }

    // On successful cal to readdir_r, result and &entry should point to the same
    // data; a NULL temp pointer but return of 0 means that we reached the end of the 
    // directory stream; finally, a NULL temp pointer with a positive return value
    // means an error occurred.
    dirent* result = nullptr;
    dirent* entry = (dirent*)buffer;
    int ret = readdir_r(dir, entry, &result);
    if (ret == 0)
    {
        if (result != nullptr)
        {
            assert(result == entry);
            ConvertDirent(*entry, outputEntry);
        }
        else
        {
            ret = -1; // errno values are positive so signal the end-of-stream with a non-error value
            *outputEntry = { };
        }
    }
    else
    {
        *outputEntry = { };
    }

    return ret;
}
开发者ID:hariviknesh,项目名称:corefx,代码行数:39,代码来源:pal_io.cpp


示例15: ls

inline Try<std::list<std::string>> ls(const std::string& directory)
{
  DIR* dir = opendir(directory.c_str());

  if (dir == nullptr) {
    // Preserve `opendir` error.
    return ErrnoError("Failed to opendir '" + directory + "'");
  }

  dirent* temp = (dirent*) malloc(os::dirent_size(dir));

  if (temp == nullptr) {
    // Preserve `malloc` error.
    ErrnoError error("Failed to allocate directory entries");
    closedir(dir);
    return error;
  }

  std::list<std::string> result;
  struct dirent* entry;
  int error;

  while ((error = readdir_r(dir, temp, &entry)) == 0 && entry != nullptr) {
    if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
      continue;
    }
    result.push_back(entry->d_name);
  }

  free(temp);
  closedir(dir);

  if (error != 0) {
    // Preserve `readdir_r` error.
    return ErrnoError("Failed to read directories");
  }

  return result;
}
开发者ID:EronWright,项目名称:mesos,代码行数:39,代码来源:ls.hpp


示例16: opendir

bool Motor::connect(enum MotorPort port)
{
	DIR *dir = opendir(motorRootPath);
	struct dirent dent;
	struct dirent *dptr;
	unsigned long n;
	const size_t pathSize = MOTORPATHNAME_MAX;
	char path[pathSize];
	const size_t bufferSize = 5;
	char buffer[bufferSize];

	if (dir == nullptr)
		return false;

	do {
		if (readdir_r(dir, &dent, &dptr) != 0 || dptr == 0)
			goto failed;
		/* We disregard all directories that start with a . */
		if (dent.d_name[0] == '.')
			continue;
		snprintf(path, pathSize, "%s/%s/port_name", motorRootPath,
			 dent.d_name);
		memset(buffer, 0, bufferSize);
		n = readfile(path, buffer, bufferSize);
		/* We only care about the first 4 chars, if they are contain
		 * the correct magic out[ABCD] */
		if (n >= 4 && strncmp(buffer, portNames[port], 4) == 0)
			break;
	} while(true);
	snprintf(motorPath, sizeof(motorPath), "%s/%s", motorRootPath,
		 dent.d_name);
	closedir(dir);
	setupFastPaths(dent.d_name);
	scanParams();
	return paramsOK;
failed:
	closedir(dir);
	return false;
}
开发者ID:cunctator,项目名称:holorobot,代码行数:39,代码来源:motor.cpp


示例17: while

int Storage::cleanSubDir(const char *dir) {
   static bool reportedError=false; //avoid filling up syslog
   DIR *d=opendir(dir);
   bool hadError=false;
   int bytesDeleted=0;
   if (d) {
      struct dirent *txtfile, path;
      struct stat txtfilestat;
      char fullPath[PATH_MAX];
      int filesize;
      while ( (!readdir_r(d, &path, &txtfile) && txtfile != NULL) ) {
         int len=strlen(txtfile->d_name);
         //check that the file end with .vtx to avoid accidents and disasters
         if (strcmp(txtfile->d_name+len-4, ".vtx")==0) {
            snprintf(fullPath, PATH_MAX, "%s/%s", dir, txtfile->d_name);
            stat(fullPath, &txtfilestat);
            filesize=actualFileSize(txtfilestat.st_size);
            int ret=unlink(fullPath);
            if (ret==0)
               bytesDeleted+=filesize;
            else
               hadError=ret;
         }
      }
      closedir(d);
      rmdir(dir);
   } else {
      if (!reportedError) {
         esyslog("OSD-Teletext: Error opening teletext storage subdirectory \"%s\": %s", dir, strerror(errno));
         reportedError=true;
      }
   }

   if (hadError && !reportedError) {
      esyslog("OSD-Teletext: Error removing teletext storage subdirectory \"%s\": %s", dir, strerror(hadError));
      reportedError=true;
   }
   return bytesDeleted;
}
开发者ID:rofafor,项目名称:vdr-plugin-osdteletext,代码行数:39,代码来源:storage.c


示例18: readIconFrom

static QIcon readIconFrom(const QByteArray& path, const QByteArray& iconname, int depth = 0)
{
    if (path.isEmpty() || depth > MAX_ICON_RECURSE_DEPTH)
        return QIcon();

    QByteArray fn;
    static const char* exts[] = { ".xpm", ".png", 0 };
    for (int i = 0; ; ++i) {
        if (!exts[i])
            break;
        fn = path + iconname + exts[i];
        if (QFile::exists(QString::fromLocal8Bit(fn.constData(), fn.size()))) {
            QIcon icn(QString::fromLocal8Bit(fn.constData(), fn.size()));
            return icn;
        }
    }

    QIcon icn;
    DIR *dir = opendir(path.constData());
    if (!dir)
        return QIcon();
    struct dirent d, *res;
    while (readdir_r(dir, &d, &res) == 0 && res != 0) {
        if (d.d_type == DT_DIR) {
            if (strcmp(d.d_name, ".") && strcmp(d.d_name, "..")) {
                icn = readIconFrom(path + QByteArray(d.d_name) + '/', iconname, depth + 1);
                if (!icn.isNull()) {
                    closedir(dir);
                    return icn;
                }
            }
        }
    }

    closedir(dir);

    return QIcon();
}
开发者ID:Andersbakken,项目名称:Genesis,代码行数:38,代码来源:FileIconProvider.cpp


示例19: acpDirRead

/**
 * read the next directory entry in the directory stream
 *
 * @param aDir pointer to the directory stream object
 * @param aEntryName pointer to the constant string object to get the file name
 * @return result code
 *
 * The returned file name is pointer to the internal buffer
 * of directory stream object.
 * So, the content of the file name should not be modified.
 * The file name is always null terminated.
 *
 * it returns #ACP_RC_EOF if there is no more file in the directory
 */
ACP_EXPORT acp_rc_t acpDirRead(acp_dir_t *aDir, acp_char_t **aEntryName)
{
    struct dirent *sEntry = NULL;
    acp_sint32_t   sRet;

    ACP_RC_SET_OS_ERROR(ACP_RC_SUCCESS);

    sRet  = readdir_r(aDir->mHandle, aDir->mEntry, &sEntry);

    if (sRet != 0)
    {
#if defined(ALTI_CFG_OS_AIX)
        if (ACP_RC_GET_OS_ERROR() != ACP_RC_SUCCESS)
        {
            return ACP_RC_GET_OS_ERROR();
        }
        else
        {
            return ACP_RC_EOF;
        }
#else
        return sRet;
#endif
    }
    else
    {
        if (sEntry == NULL)
        {
            return ACP_RC_EOF;
        }
        else
        {
            *aEntryName = sEntry->d_name;

            return ACP_RC_SUCCESS;
        }
    }
}
开发者ID:doong123,项目名称:altibase,代码行数:52,代码来源:acpDir.c


示例20: load_plugin_dir

/**
 * process a directory for plugins
 *
 * @returns TRUE if at least one plugin loaded successfully
 */
int load_plugin_dir(char *plugindir) {
    DIR *d_plugin;
    char de[sizeof(struct dirent) + MAXNAMLEN + 1]; /* ?? solaris  */
    struct dirent *pde;
    char *pext;
    char *perr=NULL;
    int loaded=FALSE;
    char plugin[PATH_MAX];

    if((d_plugin=opendir(plugindir)) == NULL) {
        DPRINTF(E_LOG,L_MAIN,"Error opening plugin dir %s.  Ignoring\n",
                plugindir);
        return FALSE;

    } else {
        while((readdir_r(d_plugin,(struct dirent *)de,&pde) != 1) && pde) {
                pext = strrchr(pde->d_name,'.');
                if((pext) && ((strcasecmp(pext,".so") == 0) ||
                   (strcasecmp(pext,".dylib") == 0) ||
                   (strcasecmp(pext,".dll") == 0))) {
                    /* must be a plugin */
                    snprintf(plugin,PATH_MAX,"%s%c%s",plugindir,
                             PATHSEP,pde->d_name);
                    if(plugin_load(&perr,plugin) != PLUGIN_E_SUCCESS) {
                        DPRINTF(E_LOG,L_MAIN,"Error loading plugin %s: %s\n",
                                plugin,perr);
                        free(perr);
                        perr = NULL;
                    } else {
                        loaded = TRUE;
                    }
                }
        }
        closedir(d_plugin);
    }

    return loaded;
}
开发者ID:GunioRobot,项目名称:rtn56u,代码行数:43,代码来源:main.c



注:本文中的readdir_r函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ readfifo函数代码示例发布时间:2022-05-30
下一篇:
C++ readdir函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap