@@ -22,7 +22,7 @@ int in_fd; // 표준 입력
22
22
int out_fd ; // 표준 출력
23
23
int err_fd ; // 표준 에러
24
24
25
- file_node change_list [BUFFER_SIZE ]; // 변경 목록
25
+ file_node change_list [MAX_BUFFER_SIZE ]; // 변경 목록
26
26
char * * saved_argv ;
27
27
int saved_argc ;
28
28
bool src_is_dir = false;
@@ -394,9 +394,9 @@ bool compare_file(file_node *src_file, file_node *dst_file) // 파일 정보 비
394
394
while (now != NULL ) {
395
395
396
396
#ifdef DEBUG
397
- printf ("compare_file(): src_file->name = %s, dst_file->name = %s\n" , src_file -> name + strlen (pwd ) + 1 , now -> name + strlen (dst_path ) + 1 );
397
+ printf ("compare_file(): src_file->name = %s, dst_file->name = %s\n" , src_file -> name + strlen (src_path ) - strlen ( get_file_name ( src_path )) , now -> name + strlen (dst_path ) + 1 );
398
398
#endif
399
- if (!strcmp (src_file -> name + strlen (pwd ) + 1 , now -> name + strlen (dst_path ) + 1 )) { // 파일 이름이 같은 경우
399
+ if (!strcmp (src_file -> name + strlen (src_path ) - strlen ( get_file_name ( src_path )) , now -> name + strlen (dst_path ) + 1 )) { // 파일 이름이 같은 경우
400
400
401
401
#ifdef DEBUG
402
402
printf ("compare_file(): file found\n" );
@@ -482,7 +482,7 @@ int write_change_list(file_node *head, int idx, int status, bool is_first) //
482
482
break ;
483
483
}
484
484
485
- if (option_r || is_first )
485
+ if (option_r || is_first )// R옵션이 존재하거나 첫번째 레벨일 경우
486
486
if (now -> child != NULL )
487
487
idx = write_change_list (now -> child , idx , status , false);
488
488
@@ -505,7 +505,8 @@ void renewal(int count) // 파일 동기화
505
505
struct utimbuf attr ;
506
506
size_t length ;
507
507
508
- sprintf (path , "%.*s/%s" , (int )strlen (dst_path ), dst_path , get_file_name (src_path ));
508
+ // 타겟 디렉토리가 존재하지 않을경우 동기화 디렉토리에 생성
509
+ sprintf (path , "%.*s/%s" , (int )strlen (dst_path ), dst_path , get_file_name (src_path ));
509
510
if (src_is_dir && access (path , F_OK ) < 0 ) {
510
511
lstat (src_path , & statbuf );
511
512
mkdir (path , statbuf .st_mode );
@@ -529,7 +530,10 @@ void renewal(int count) // 파일 동기화
529
530
memset (path , 0 , MAX_BUFFER_SIZE );
530
531
531
532
lstat (change_list [i ].name , & statbuf );
532
- sprintf (path , "%.*s/%s" , (int )strlen (dst_path ), dst_path , change_list [i ].name + strlen (pwd ) + 1 ); // 동기화 파일 경로 생성
533
+ sprintf (path , "%.*s/%s" , (int )strlen (dst_path ), dst_path , change_list [i ].name + strlen (src_path ) - strlen (get_file_name (src_path ))); // 동기화 파일 경로 생성
534
+ #ifdef DEBUG
535
+ printf ("renewal: path = %s\n" , path );
536
+ #endif
533
537
534
538
if (S_ISDIR (statbuf .st_mode ))
535
539
mkdir (path , 0755 );
0 commit comments