#At file:///home/msvensson/mysql/tmp/ZA7aKV__lr/7.1/ based on revid:magnus.blaudd@strippedgin4r1q
3765 Magnus Blåudd 2010-08-23 [merge]
Merge 7.0 -> 7.1
modified:
storage/ndb/include/portlib/NdbDir.hpp
storage/ndb/src/common/portlib/NdbDir.cpp
=== modified file 'storage/ndb/include/portlib/NdbDir.hpp'
--- a/storage/ndb/include/portlib/NdbDir.hpp 2010-08-23 08:46:34 +0000
+++ b/storage/ndb/include/portlib/NdbDir.hpp 2010-08-23 11:20:11 +0000
@@ -32,7 +32,16 @@ public:
int open(const char* path);
void close(void);
+
+ /*
+ Return the next regular file or NULL if no more file found
+ */
const char* next_file(void);
+
+ /*
+ Return the next entry(file, dir, symlink etc.) or NULL if no
+ more entries found
+ */
const char* next_entry(void);
};
=== modified file 'storage/ndb/src/common/portlib/NdbDir.cpp'
--- a/storage/ndb/src/common/portlib/NdbDir.cpp 2010-08-23 08:46:34 +0000
+++ b/storage/ndb/src/common/portlib/NdbDir.cpp 2010-08-23 11:20:11 +0000
@@ -42,7 +42,7 @@ class DirIteratorImpl {
"%s/%s", m_path, dp->d_name);
struct stat buf;
- if (stat(m_buf, &buf))
+ if (lstat(m_buf, &buf)) // Use lstat to not follow symlinks
return false; // 'stat' failed
return S_ISREG(buf.st_mode);
@@ -75,14 +75,14 @@ public:
m_dirp = NULL;
}
- const char* next_entry(bool& is_directory)
+ const char* next_entry(bool& is_reg)
{
struct dirent* dp = readdir(m_dirp);
if (dp == NULL)
return NULL;
- is_directory = !is_regular_file(dp);
+ is_reg = is_regular_file(dp);
return dp->d_name;
}
};
@@ -97,6 +97,9 @@ class DirIteratorImpl {
bool is_dir(const WIN32_FIND_DATA find_data) const {
return (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
}
+ bool is_regular_file(const WIN32_FIND_DATA find_data) const {
+ return (find_data.dwFileAttributes & FILE_ATTRIBUTE_NORMAL);
+ }
public:
DirIteratorImpl():
@@ -129,12 +132,12 @@ public:
m_find_handle = NULL;
}
- const char* next_entry(bool& is_directory)
+ const char* next_entry(bool& is_reg)
{
if (m_first || FindNextFile(m_find_handle, &m_find_data))
{
m_first = false;
- is_directory = is_dir(m_find_data);
+ is_reg = is_regular_file(m_find_data);
return m_find_data.cFileName;
}
return NULL;
@@ -167,19 +170,19 @@ void NdbDir::Iterator::close(void)
const char* NdbDir::Iterator::next_file(void)
{
- bool is_dir;
+ bool is_reg;
const char* name;
- while((name = m_impl.next_entry(is_dir)) != NULL){
- if (!is_dir)
- return name; // Found some sort of file
- }
+ while((name = m_impl.next_entry(is_reg)) != NULL){
+ if (is_reg == true)
+ return name; // Found regular file
+ }
return NULL;
}
const char* NdbDir::Iterator::next_entry(void)
{
- bool is_dir;
- return m_impl.next_entry(is_dir);
+ bool is_reg;
+ return m_impl.next_entry(is_reg);
}
mode_t NdbDir::u_r(void) { return IF_WIN(0, S_IRUSR); };
@@ -406,7 +409,7 @@ TAPTEST(DirIterator)
// Build dir tree
build_tree(path);
- // Test to iterate over filesa
+ // Test to iterate over files
{
NdbDir::Iterator iter;
CHECK(iter.open(path) == 0);
Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20100823143041-x90ak5b5c5r8ob4o.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.1 branch (magnus.blaudd:3765) | Magnus Blåudd | 24 Aug |