fs::lsdir() improvements
Bug #986580 reported by
Paul J. Lucas
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zorba |
Fix Released
|
Low
|
Paul J. Lucas |
Bug Description
I noticed that this function was added. There are a few of problems with its implementation:
1. It forces the user to use a vector. What if I want to use a list? Or something else?
2. It uses std::string. The majority of the Zorba code base uses zstring.
3. It always reads the entire directory whether you want it or not. (WHat if there are 10,000 files in a directory?) Instead, it ought to provide an iterator that you can stop any time you please.
4. After the initial check for an error from opendir(), the code doesn't check for any subsequent errors, e.g., it does not check closedir() for error.
Related branches
lp:~zorba-coders/zorba/bug-986580
- Rodolfo Ochoa: Approve
- Cezar Andrei: Approve
-
Diff: 1326 lines (+298/-764)16 files modifiedCMakeLists.txt (+7/-0)
NOTICE.txt (+0/-18)
NOTICE.xml (+0/-16)
src/api/fileimpl.cpp (+6/-17)
src/api/fileimpl.h (+3/-4)
src/unit_tests/CMakeLists.txt (+1/-0)
src/unit_tests/test_fs_iterator.cpp (+54/-0)
src/unit_tests/unit_test_list.h (+1/-0)
src/unit_tests/unit_tests.cpp (+1/-0)
src/util/CMakeLists.txt (+0/-1)
src/util/dir.cpp (+0/-175)
src/util/dir.h (+0/-100)
src/util/file.cpp (+3/-1)
src/util/fs_util.cpp (+129/-31)
src/util/fs_util.h (+93/-29)
src/util/win32/dirent.h (+0/-372)
Changed in zorba: | |
status: | Triaged → In Progress |
Changed in zorba: | |
status: | In Progress → Fix Committed |
milestone: | none → 2.5 |
Changed in zorba: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
I also took a look at the win32/dirent.h file that implements opendir(), readdir(), etc., for Windows. That code uses only the ASCII Win32 API and so won't work for Unicode path/file names. Hence, this code should not be used.
I also noticed that the files util/dir.h and util/dir.cpp exist and ALREADY implement iterating over a directory and the code ALRAEDY works properly with Unicode path/file names under Windows.
So why was fs::lsdir() added at all?
I'll clean-up the code in util/dir.h and absorb it into fs_util.h