Anonymous | Login | Signup for a new account | 2024-12-02 08:23 CET |
My View | View Issues | Change Log | Roadmap |
View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0000140 | aMule | Misc | public | 2004-09-21 16:17 | 2004-09-25 19:38 | ||||
Reporter | volpol | ||||||||
Assigned To | Kry | ||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | resolved | Resolution | fixed | ||||||
Platform | OS | OS Version | |||||||
Product Version | |||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0000140: CDirIterator::FindNextFile() always returns wxEmptyString (in aMule-cvs-20040921) | ||||||||
Description | CDirIterator::FindNextFile() doesn't work as intended with reiserfs (always returns wxEmptyString) due to the fact that readdir() always returns DT_UNKNOWN for d_type. please refer to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=210861 [^] for more info. | ||||||||
Tags | No tags attached. | ||||||||
Fixed in Revision | |||||||||
Operating System | |||||||||
Attached Files | |||||||||
Notes | |
(0000261) volpol (developer) 2004-09-21 16:45 |
not sure if it's useful but here's the version of FindNextFile i am using currently. wxString CDirIterator::FindNextFile() { struct dirent *dp; dp = readdir(DirPtr); bool found = false; struct stat* buf=(struct stat*)malloc(sizeof(struct stat)); wxString FoundName; wxString tname; while (dp!=NULL && !found) { tname=DirStr+char2unicode(dp->d_name); stat (unicode2char(tname),buf); if (S_ISREG(buf->st_mode)){ if (type == CDirIterator::File) found = true; else dp = readdir(DirPtr);} else if (S_ISDIR(buf->st_mode)){ if (type == CDirIterator::Dir) found = true; else dp = readdir(DirPtr);} else // unix socket, block device, etc if ((type == CDirIterator::Any)) // return anything. found = true; else dp = readdir(DirPtr); if (found) { FoundName = char2unicode(dp->d_name); if ( (!FileMask.IsEmpty() && !FoundName.Matches(FileMask)) || FoundName.IsSameAs(wxT(".")) || FoundName.IsSameAs(wxT(".."))) { found = false; dp = readdir(DirPtr); } } } free(buf); if (dp!=NULL) { return DirStr + FoundName; } else { return wxEmptyString; } } |
(0000263) Kry (manager) 2004-09-22 17:18 |
Many thanks, With small changes, it will be on CVS ASAP. Sorry for the bug :) |
(0000267) volpol (developer) 2004-09-22 23:51 |
it's ok. keep up the good work! =) |
(0000268) Kry (manager) 2004-09-23 01:10 edited on: 2004-09-23 01:14 |
This is my final version: wxString CDirIterator::FindNextFile() { struct dirent *dp; dp = readdir(DirPtr); bool found = false; wxString FoundName; struct stat* buf=(struct stat*)malloc(sizeof(struct stat)); while (dp!=NULL && !found) { if ((type == CDirIterator::Any)) { // return anything. found = true; } else { switch (dp->d_type) { case DT_DIR: if (type == CDirIterator::Dir) { found = true; } else { dp = readdir(DirPtr); } break; case DT_REG: if (type == CDirIterator::File) { found = true; } else { dp = readdir(DirPtr); } break; default: // Fallback to stat stat(unicode2char(tname),buf); if (S_ISREG(buf->st_mode)) { if (type == CDirIterator::File) { found = true; } else { dp = readdir(DirPtr); } } else { if (S_ISDIR(buf->st_mode)) { if (type == CDirIterator::Dir) { found = true; } else { dp = readdir(DirPtr); } } else { // unix socket, block device, etc dp = readdir(DirPtr); } } break; } } if (found) { FoundName = char2unicode(dp->d_name); if ( (!FileMask.IsEmpty() && !FoundName.Matches(FileMask)) || FoundName.IsSameAs(wxT(".")) || FoundName.IsSameAs(wxT(".."))) { found = false; dp = readdir(DirPtr); } } } free(buf); if (dp!=NULL) { return DirStr + FoundName; } else { return wxEmptyString; } } Is much longer than yours, but I like it more ;) It avoids stat while we can :) edited on: 09-23-04 01:10 edited on: 09-23-04 01:14 |
(0000269) volpol (developer) 2004-09-23 01:18 |
that's understandable since i only have to make it work for me while you have to make it portable =p where is tname defined in your version by the way? and also one can eliminate a few if's by using something like (S_REG(...) && (type == CDirIterator::File)) i realized it a bit later...back then i was too eager to make aMule finally find my temporary and shared files =p |
(0000270) Kry (manager) 2004-09-23 01:27 edited on: 2004-09-23 01:31 |
lol, ok, I won't poste code again BEFORe compiling it ;) stat(unicode2char(DirStr + dp->d_name),buf); Want this to be your first patch to aMule? (one of many!) go on and paste your optimisations :) edited on: 09-23-04 01:31 |
(0000274) volpol (developer) 2004-09-23 23:55 |
hmmm...one can concatenate wsString and char[] like that...i didn't know. lol, or maybe that's how it's done in c++. i would probably give strcat() a chance =p anyway further optimization seems to be unnecessary. waiting for the fix to appear in CVS. |
(0000277) Kry (manager) 2004-09-25 19:38 |
Yo, on CVS |
Issue History | |||
Date Modified | Username | Field | Change |
2004-09-21 16:17 | volpol | New Issue | |
2004-09-21 16:45 | volpol | Note Added: 0000261 | |
2004-09-22 17:18 | Kry | Note Added: 0000263 | |
2004-09-22 17:21 | Kry | Status | new => acknowledged |
2004-09-22 23:51 | volpol | Note Added: 0000267 | |
2004-09-23 01:10 | Kry | Note Added: 0000268 | |
2004-09-23 01:10 | Kry | Note Edited: 0000268 | |
2004-09-23 01:14 | Kry | Note Edited: 0000268 | |
2004-09-23 01:18 | volpol | Note Added: 0000269 | |
2004-09-23 01:27 | Kry | Note Added: 0000270 | |
2004-09-23 01:28 | Kry | Note Added: 0000271 | |
2004-09-23 01:29 | Kry | Note Deleted: 0000271 | |
2004-09-23 01:31 | Kry | Note Edited: 0000270 | |
2004-09-23 23:55 | volpol | Note Added: 0000274 | |
2004-09-25 19:38 | Kry | Status | acknowledged => resolved |
2004-09-25 19:38 | Kry | Resolution | open => fixed |
2004-09-25 19:38 | Kry | Assigned To | => Kry |
2004-09-25 19:38 | Kry | Note Added: 0000277 |
Copyright © 2000 - 2024 MantisBT Team |