[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0dbe2eec5e
From: |
Giuseppe Scrivano |
Subject: |
[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0dbe2eec5ec1ae7b563ebe861484111d1fbe92fa |
Date: |
Mon, 05 Oct 2009 19:52:50 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".
The branch, master has been updated
via 0dbe2eec5ec1ae7b563ebe861484111d1fbe92fa (commit)
from eb03e44b3f6b73bca1aa91e713a5112a907c8fe0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0dbe2eec5ec1ae7b563ebe861484111d1fbe92fa
Author: Giuseppe Scrivano <address@hidden>
Date: Mon Oct 5 21:50:44 2009 +0200
Refactor common code in a single function.
diff --git a/myserver/include/base/find_data/find_data.h
b/myserver/include/base/find_data/find_data.h
index b26c2bd..96d08de 100644
--- a/myserver/include/base/find_data/find_data.h
+++ b/myserver/include/base/find_data/find_data.h
@@ -78,6 +78,7 @@ public:
}
private:
+ int find (const char *filename);
# ifdef WIN32
_finddata_t fd;
intptr_t ff;
diff --git a/myserver/src/base/find_data/find_data.cpp
b/myserver/src/base/find_data/find_data.cpp
index 6d567b9..6d22c31 100644
--- a/myserver/src/base/find_data/find_data.cpp
+++ b/myserver/src/base/find_data/find_data.cpp
@@ -55,37 +55,59 @@ FindData::~FindData ()
*/
int FindData::findfirst (const char *filename)
{
+ return find (filename);
+}
+
+/*!
+ * Find the next file in the directory.
+ */
+int FindData::findnext ()
+{
+ return find (NULL);
+}
+
+int FindData::find (const char *filename)
+{
#ifdef WIN32
- string filenameStar;
- filenameStar.assign (filename);
- // trim ending '/' or '\'
- string::size_type slashBackSlash = filenameStar.find_last_not_of ("/\\");
- filenameStar.erase (slashBackSlash + 1);
- filenameStar.append ("\\*");
-
- ff = _findfirst (filenameStar.c_str (), &fd );
- if (ff!=-1)
+ int ret;
+
+ if (filename)
+ {
+ string filenameStar;
+ filenameStar.assign (filename);
+ /* trim trailing '/' or '\' */
+ string::size_type slashBackSlash = filenameStar.find_last_not_of ("/\\");
+ filenameStar.erase (slashBackSlash + 1);
+ filenameStar.append ("\\*");
+
+ ret = ff = _findfirst (filenameStar.c_str (), &fd );
+ }
+ else
+ ret = _findnext (ff, &fd) ? -1 : 0 ;
+
+ if (ret != -1)
{
name = fd.name;
attrib = fd.attrib;
time_write = fd.time_write;
size = fd.size ;
- return 0;
}
- else
- return ff;
+ return ret;
#else
struct dirent * dirInfo;
- dirName.assign (filename);
- if (dirName[dirName.length () - 1] == '/')
- dirName.erase (dirName.length () - 1);
+ if (filename)
+ {
+ dirName.assign (filename);
+ if (dirName[dirName.length () - 1] == '/')
+ dirName.erase (dirName.length () - 1);
- dh = opendir (dirName.c_str ());
+ dh = opendir (dirName.c_str ());
- if (dh == NULL)
- return -1;
+ if (dh == NULL)
+ return -1;
+ }
dirInfo = readdir (dh);
@@ -118,56 +140,6 @@ int FindData::findfirst (const char *filename)
}
/*!
- * Find the next file in the directory.
- */
-int FindData::findnext ()
-{
-#ifdef WIN32
- if (!ff)
- return -1;
- int ret = _findnext (ff, &fd) ? -1 : 0 ;
- if (ret != -1)
- {
- name = fd.name;
- attrib = fd.attrib;
- time_write = fd.time_write;
- size = fd.size ;
- }
- return ret;
-#else
- struct dirent * dirInfo;
- string tempName;
-
- dirInfo = readdir (dh);
-
- if (dirInfo == NULL)
- return -1;
-
- name = dirInfo->d_name;
-
-# ifdef HAVE_FSTATAT
- if (fstatat (dirfd (dh), dirInfo->d_name, &stats, 0))
- return -1;
-# else
- tempName.assign (dirName);
- tempName.append ("/");
- tempName.append (dirInfo->d_name);
-
- if (stat (tempName.c_str (), &stats))
- return -1;
-# endif
-
- if (S_ISDIR (stats.st_mode))
- attrib = FILE_ATTRIBUTE_DIRECTORY;
- else
- attrib = 0;
- time_write = stats.st_mtime;
- size = stats.st_size;
- return 0;
-#endif
-}
-
-/*!
* Free the used resources.
*/
int FindData::findclose ()
-----------------------------------------------------------------------
Summary of changes:
myserver/include/base/find_data/find_data.h | 1 +
myserver/src/base/find_data/find_data.cpp | 108 ++++++++++-----------------
2 files changed, 41 insertions(+), 68 deletions(-)
hooks/post-receive
--
GNU MyServer
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0dbe2eec5ec1ae7b563ebe861484111d1fbe92fa,
Giuseppe Scrivano <=