C언어에서 리눅스에서 사용하는 #include <unistd.h> #include <dirent.h> 헤더파일을 윈도우7에서 사용 할 수 있게 할 수 있나요??

seojh1431의 이미지

오픈소스를 구해서 이 소스를 수정하려고 하는데 저의 운영체제는 윈7이구요 씨언어 구동환경은 microsoft visual c++ 2008 입니다.
"dirent.h" 과 "unistd.h" 은 없는 헤더파일이라고 나오더군요...... 다른 방법 없을까요?

#include "sys/stat.h"
#include "sys/types.h"
#include "unistd.h"
#include "dirent.h"
#include "stdio.h"
 
 
// 인수로 전달 받은 디렉토리의 하위 디렉토리를 출력하는 함수.
void subdirOutput(char *wd);
 
 
 
// 디렉토리 들여쓰기를 위한 디렉토리 경로 레벨 저장용.
int indent = 0;
 
 
 
void main()
{
	printf("Sub-Directory Ouput!!!\n");
	printf("----------------------\n");
 
	// 현재 디렉토리의 하위 디렉토리를 출력시킨다.
	subdirOutput(".");
 
 
}
 
void subdirOutput(char *wd)
{
	struct dirent *dentry;
	struct stat fstat;
	DIR *dirp;
	int i;
 
	// 인수로 전달받은 디렉토리로 이동한다.
	if(chdir(wd) < 0) 
	{
		printf("error: chdir..\n");
		exit(1);
	}
 
 
 
	// 이동한 현재 디렉토리를 연다.
	if((dirp = opendir(".")) == NULL) 
	{
		printf("error: opendir..\n");
		exit(1);
	}
 
 
 
	// 열린 디렉토리의 모든 항목을 읽는다.
	while(dentry = readdir(dirp)) 
	{
 
 
 
		// 디렉토리의 항목의 아이노드번호가 0 아닌 것을 찾는다.
		// 아이노드번호가 0 이면 그 항은 삭제가 된 것이다.
		if(dentry->d_ino != 0) 
		{
 
 
 
			// 읽어혼 항목중 "."(현재디렉토리)와 ".."(부모디렉토리)는 건너뛴다.
			// 이는 하위 디렉토리를 출력하는 것이기 때문에 제외하는 것이다.
			if((!strcmp(dentry->d_name, ".")) || (!strcmp(dentry->d_name, "..")))
				continue;
 
 
 
			// 현재 항목의 상태정보를 가져온다.
			stat(dentry->d_name, &fstat);
 
 
 
			// 하위 디렉토리의 출력을 보기 좋게 하기 위해서
			// 디렉토리 경로 레벨별로 Tab으로 구분한다.
			for(i = 0; i < indent; i++)
				printf("\t");
 
			// 현재 항목의 상태가 디렉토리일 경우 
			// 항목명을 출력하고 디렉토리 경로 레벨을 증가시킨 후
			// subdirOutput함수를 재귀 호출하면서 현재 항목명을 인수로 전달한다.
 
			if(S_ISDIR(fstat.st_mode)) 
			{
				printf("%s\n", dentry->d_name);
				indent++;
				subdirOutput(dentry->d_name);
 
				// 현재 항목의 상태가 디렉토리가 아닐 경우
				// 디렉토리명을 보기 좋게 출력하기 위해
				// Tab으로 이동시킨 커서를 되돌린다.
			} 
 
			else 
			{
				printf("\r");
			}
		}
	}
 
 
 
	// 열린 현재 디렉토리의 사용이 끝났으므로 닫아준다.
	// 인수로 전달받은 디렉토리의 하위 디렉토리 출력이 끝났으므로 
	// 디렉토리 경로 레벨을 감소 시킨후 부모 디렉토리로 이동한다.
	closedir(dirp);
	indent--;
	chdir("..");
}
익명 사용자의 이미지

코드를 안 바꾸려면 Visual Studio대신 minGW나 Cygwin에서 빌드하세요.

김모씨의 이미지

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.