⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 win32_dirent.h

📁 嵌入式GUI OpenGL源代码。OpenGL是嵌入式开发中常用的一种GUI系统。
💻 H
字号:
#ifndef __win32_dirent__
#define __win32_dirent__

/* For Win32 that lacks Unix direct support. */

#include <windows.h>
#include <string.h>

struct dirent {
  char d_name[MAX_PATH];
};

typedef struct {
  WIN32_FIND_DATA wfd;
  HANDLE hFind;
  struct dirent de;
} DIR;

static DIR *
opendir(char *pSpec)
{
  DIR *pDir = malloc(sizeof(DIR));
  /* XXX Windows 95 has problems opening up "." though Windows NT does this
     fine?  Open "*" instead of "." to be safe. -mjk */
  pDir->hFind = FindFirstFile(strcmp(pSpec, ".") ? pSpec : "*",
    &pDir->wfd);
  return pDir;
}

static void
closedir(DIR * pDir)
{
  FindClose(pDir);
  free(pDir);
}

static struct dirent *
readdir(DIR *pDir)
{
  if (pDir->hFind) {
    strcpy(pDir->de.d_name, pDir->wfd.cFileName);
    if (!FindNextFile(pDir->hFind, &pDir->wfd))
      pDir->hFind = NULL;
    return &pDir->de;
  }
  return NULL;
}

#define fclose(f)  { if (f!=NULL) fclose(f); }

#endif /* __win32_dirent__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -