#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/types.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/socket.h>
#define ERR -1
<?xml:namespace prefix = o ns = \"urn:schemas-microsoft-com:office:office\" /><o:p></o:p>
void usage(void);
char *command_name;
char *rindex(const char *s, int c);
char *p;
char answer[32];
<o:p></o:p>
int main(int argc, char *argv[])
{
DIR *dir;
struct stat m_dir, source_file, object_file;
int fd_des, fd_src;
int source, object; //( 원본 : source, 대상 : object)
int buf;
int read_number;
int T_option = 0, F_option = 0;
<o:p></o:p>
if( ( command_name = rindex( argv[0], \'/\' ) ) != NULL )
command_name++;
else
command_name = argv[0];
<o:p></o:p>
//printf(\"1%s\\n,1%s\\n\",argv[1],argv[2]);
while( --argc > 0)
{
//printf(\"2%s\\n,2%s\\n\",argv[1],argv[2]);
if( **(++argv) == \'-\')
{
p = *argv;
while(*++p)
{
switch(*p)
{
case \'f\' :
//F_option
break;
<o:p></o:p>
case \'i\':
T_option = 1;
break;
<o:p></o:p>
case \'m\':
//M_option
break;
<o:p></o:p>
case \'b\':
//B_option
break;
<o:p></o:p>
default :
usage();
}
}
} *--argv;
<o:p></o:p>
if( T_option == 1 )
{
printf(\"%d\", T_option);
printf(\"%s 덮어쓰시겠습니까?(y or n)\", argv[2]);
fgets(answer,sizeof(answer),stdin);
if(! strncmp(answer, \"y\\n\", 2))
{
rename(argv[2],argv[3]);
printf(\"file move\\n\");
}
exit(0);
}
if(argc =! 3)
usage();
if(fd_src=open(argv[1],O_RDONLY) < 0 ) //
{
printf(\"Erorr : %s .\\n\",argv[1]);
exit(1);
}
if(fd_des=open(argv[2],O_WRONLY|O_CREAT|O_TRUNC) < 0 )
{
printf(\"Error : %s. \\n\", argv[2]);
exit(1);
/* if(S_ISDIR(source_file.st_mode & S_IFMT))
{
printf(\"Erorr : %s \". \\n\", argv[2]);
exit(1);
}*/
}
printf(\"%s,%s\", argv[1],argv[2]);
if(rename(argv[1],argv[2]) <0)
{
perror(\"rename\");
exit(1);
}
else
{
printf(\"file move\\n\");
}
exit(0);
}
}
void usage(void)
{
fprintf(stderr, \"Usage()파일이동[옵션][source][object]\",command_name);
exit(1);
}
소스가 이렇게 있는데 이 소스는
리눅스 gcc에서 mv명령어 옵션 사용해서 파일 이동 하는 소스거든요??
근데 여기서 i옵션 사용 소스는 있는것 같은데 m,b,f옵션 사용하는 소스가 있나요?? ㅜㅜ 프로그래밍 초짜라서 ㅜㅜ
ㅋㅋㅋㅋ
으악 내눈
으악!!