>> Read Reply from No. 8153 article  
RE: [질문] 시스템(리눅스, C) 프로그래밍

등록 2000-10-12 10:43:00     조회 1
이름 code-guru    

		=============================================>>>
  Stevens 의 Advanced Programming in the UNIX Environment
  책 보세요....
  한마디로 쥑입니다.
  ====================================================>>>
  : 리눅스에서, ls 명령을 C로 짤려고 하는데요..
:
: 맘대로 안 되네요..
: 제가 원하는 건 파일 이름을 출력하고
: 그 옆에 파일 사이즈하고 변경시간을 출력하는 건데요..
: 밑에 있는데로 하면, 파일이름은 출력되는데,,
: 파일사이즈와 변경시간은?? 아무리 생각해봐도~~.
: stat structure에 st_mtime과 st_size라는 게 있던데,,,
: 이걸 어떻게 출력하죠?
:
: readdir 함수에서, 디렉토리안의 상세 정보를 원한다면
: stat에 대한 호출이 필요하다고, 책에 나와있긴 한데,,
: 도대체 어디에서 호출해 줘야 하는지...
:
: 아래에서, print 함수를 좀 봐주십시오..
:
: 답변 부탁드립니다... 안녕히~~.
:
: #include "unistd.h"
: #include "stdio.h"
: #include "dirent.h"
: #include "string.h"
: #include "sys/stat.h"
: #include "sys/types.h"
: #include "stdlib.h"
:
: void print(char* dir)
: {
: DIR* dp;
: struct dirent* entry;
: struct stat statbuf;
: // time_t time;
: // off_t size;
:
: if((dp=opendir(dir))==NULL){
: fprintf(stderr,"cannot open directory: %s",dir);
: return;
: }
: chdir(dir);
: while((entry=readdir(dp))!=NULL){
: statbuf.st_mtime;
: statbuf.st_size;
: lstat(entry->d_name,&statbuf);
: if(S_ISDIR(statbuf.st_mode))
: {
: if(strcmp(".",entry->d_name)==0 ||
: strcmp("..",entry->d_name)==0)
: continue;
: // time=S_ISDIR(statbuf.st_mtime);
: //size=S_ISDIR(statbuf.st_size);
: printf("%s directory",
: entry->d_name);
: }
: else{
: // time=S_ISDIR(statbuf.st_mtime);
: //size=S_ISDIR(statbuf.st_size);
: printf("%s file",
: entry->d_name);
: }
: }
: closedir(dp);
: }
:
: int main(int argc, char* argv<>)
: {
: char* topdir;
: if(argc>=2)
: topdir=argv[1];
: print(topdir);
: exit(0);
: }
이름
암호


>> 관련글
8153 [질문] 시스템(리눅스, C) 프로그래밍  손동균  2000.10.12  ....
  답장 RE: [질문] 시스템(리눅스, C) 프로그래밍  code-guru  2000.10.12  ....
Register [ localhost 목록보기 윗글 아랫글
글쓰기
답장쓰기 수정 삭제
정규표현식 [ 상세 검색 ]
페이지로딩: [ 1.80 초 ] 작업시간: [ 1.19 초 ]

Copyleft 1999-2026 by JSBoard Open Project
Theme Designed by IDOO All right reserved
[TOP]

적수네 동네
+
| 적수네 동네
| 공부방
| 리눅스 잡지 서고
| LSN 소스
| 링크 모음
+---+
게시판
+
| 떠들어보세!
| 질문과 답변
| 새소식과 정보
| 1원짜리 팁?
| 대화방
+---+
칼럼?
+
| 세하 훔쳐보기
| Welcome2nite
| 혜진의 염장판
+---+
리눅스 상표권
+
| 반대 서명란
| 토론 게시판
+---+
GNU
+
| GNU 선언문
| GNU GPL
| GNU 미러 목록
+---+
프로젝트?
+
| 리눅스카운터
| RC5DES
| 실질헌법 제작
+---+
커널 소식
+
| 안정 버젼: 2.4.14
+---+
테마 선택
+
LSN 방송국?
+
| OFF AIR
+---+
회원
+
| 로그인
+---+
[ 적수네 동네 ] [ 리눅스 상표권 독점 반대 ] [ 한글 리눅스 문서 프로젝트 ] [ KrLine ] [ 사랑넷 ] [ Valid HTML 4.0! ] [ SlashDot ] [ Freshmeat ]
Copyleft (C) 1998-2001 Byeong-Chan Kim . License
TIME: 1789764714
System by WYZsoft, HDD by I.O.Linux, Mizi Research, Embryo, WOWLINUX, Domain by SarangNet, Network by KrLine.