Ticket #3803: filezilla-03-dirent-to-stat.diff
File filezilla-03-dirent-to-stat.diff, 1.6 KB (added by , 16 years ago) |
---|
-
filezilla-3.1.3/src/engine/local_filesys.cpp
old new 363 363 364 364 const wxCharBuffer p = path.fn_str(); 365 365 const int len = strlen(p); 366 m_raw_path = new char[len + NAME_MAX + 2];366 m_raw_path = new char[len + _POSIX_NAME_MAX + 2]; 367 367 strcpy(m_raw_path, p); 368 368 if (len > 1) 369 369 { … … 427 427 return false; 428 428 429 429 struct dirent* entry; 430 struct stat statbuf; 430 431 while ((entry = readdir(m_dir))) 431 432 { 432 433 if (!entry->d_name[0] || … … 436 437 437 438 if (m_dirs_only) 438 439 { 439 if (entry->d_type == DT_LNK) 440 if (stat(entry->d_name, &statbuf) == -1) 441 continue; 442 if (S_ISLNK(statbuf.st_mode)) 440 443 { 441 444 bool wasLink; 442 445 strcpy(m_file_part, entry->d_name); 443 446 if (GetFileInfo(m_raw_path, wasLink, 0, 0, 0) != dir) 444 447 continue; 445 448 } 446 else if ( entry->d_type != DT_DIR)449 else if (!S_ISDIR(statbuf.st_mode)) 447 450 continue; 448 451 } 449 452 … … 505 508 return false; 506 509 507 510 struct dirent* entry; 511 struct stat statbuf; 508 512 while ((entry = readdir(m_dir))) 509 513 { 510 514 if (!entry->d_name[0] || … … 514 518 515 519 if (m_dirs_only) 516 520 { 517 if (entry->d_type == DT_LNK) 521 if (stat(entry->d_name, &statbuf) == -1) 522 continue; 523 if (S_ISLNK(statbuf.st_mode)) 518 524 { 519 525 strcpy(m_file_part, entry->d_name); 520 526 enum local_fileType type = GetFileInfo(m_raw_path, isLink, size, modificationTime, mode); … … 525 531 is_dir = type == dir; 526 532 return true; 527 533 } 528 else if ( entry->d_type != DT_DIR)534 else if (!S_ISDIR(statbuf.st_mode)) 529 535 continue; 530 536 } 531 537