You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by pi...@apache.org on 2006/05/13 18:19:17 UTC
svn commit: r406125 - /webservices/axis2/trunk/c/modules/util/dir_handler.c
Author: pini
Date: Sat May 13 09:19:16 2006
New Revision: 406125
URL: http://svn.apache.org/viewcvs?rev=406125&view=rev
Log:
Server didn't work properlly when we put a file to services directory.
Fixed that bug.
Modified:
webservices/axis2/trunk/c/modules/util/dir_handler.c
Modified: webservices/axis2/trunk/c/modules/util/dir_handler.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/dir_handler.c?rev=406125&r1=406124&r2=406125&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/dir_handler.c (original)
+++ webservices/axis2/trunk/c/modules/util/dir_handler.c Sat May 13 09:19:16 2006
@@ -13,6 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#ifndef S_ISDIR
+# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
+#endif
#include <axis2_dir_handler.h>
#include <axis2_file.h>
@@ -22,6 +26,7 @@
extern int AXIS2_ALPHASORT();
int dir_select(struct dirent *entry);
+
/**
* List the dll files in the given service or module folder path
* @param pathname path to your service or module directory
@@ -183,10 +188,16 @@
{
axis2_array_list_t *file_list = NULL;
struct stat *buf = NULL;
- int count = 1;
+ int count = 1;
int i = 0;
- struct dirent **files = NULL;
-
+ struct dirent **files = NULL;
+/**FIXME:
+ * This magic number 500 was selected as a temperary solution. It has to be
+ * replaced with dinamic memory allocation. This will be done once the use of
+ * errno after getwcd() on Windows is figured out.
+ */
+ char cwd[500];
+
/*int dir_select();*/
axis2_status_t status = AXIS2_FAILURE;
@@ -197,7 +208,10 @@
return NULL;
}*/
file_list = axis2_array_list_create(env, 0);
+ if (!getcwd(cwd, 500)) exit(1);
+ chdir(pathname);
count = AXIS2_SCANDIR(pathname, &files, dir_select, AXIS2_ALPHASORT);
+ chdir(cwd);
/* If no files found, make a non-selectable menu item */
if (count <= 0)
{
@@ -360,10 +374,14 @@
int dir_select(struct dirent *entry)
{
+ struct stat stat_p;
+
+ if (-1 == stat (entry->d_name, &stat_p))
+ return (AXIS2_FALSE);
+
axis2_char_t *rindex(const axis2_char_t *s, int c);
-
- if ((strcmp(entry->d_name, ".")== 0) ||
- (strcmp(entry->d_name, "..") == 0))
+
+ if ((entry->d_name[0] == '.') || (!S_ISDIR(stat_p.st_mode)))
{
return (AXIS2_FALSE);
}