diff examples/menu/filebrowser.c @ 602:ac2e6468a22a openvg

Replace mbe_image_surface_create_from_png() with mbe_pattern_create_image()
author Thinker K.F. Li <thinker@branda.to>
date Fri, 02 Jul 2010 13:42:22 +0800
parents 8863d23cea4b
children e030c9d4b79b
line wrap: on
line diff
--- a/examples/menu/filebrowser.c	Fri Jul 02 11:59:17 2010 +0800
+++ b/examples/menu/filebrowser.c	Fri Jul 02 13:42:22 2010 +0800
@@ -51,14 +51,14 @@
     if (strcmp(data->titles[select],"..")==0) {
 	    strcpy(path, data->curDir);
 	    len = strlen(path);
-	    for(i=len-1;i>0;i--) {
+	    for(i=len-2;i>0;i--) {
 		    if (path[i] == '/') {
 			    path[i] = 0;
 			    break;
 		    }
 	    }
     } else {
-    	snprintf(path,1024,"%s/%s", data->curDir,data->titles[select]);
+    	snprintf(path,1024,"%s%s", data->curDir,data->titles[select]);
     }
 
     MyApp_fillDirInfo(app, path);
@@ -147,6 +147,8 @@
     DIR *dir;
     struct dirent *e;
     struct fileinfo *f;
+    char *path;
+    int sz;
     int i;
 
     dir = opendir(curdir);
@@ -157,7 +159,14 @@
 
     if (data->curDir)
 	    free(data->curDir);
-    data->curDir = strdup(curdir);
+    
+    sz = strlen(curdir);
+    if(curdir[sz - 1] != '/')
+	sz++;
+    data->curDir = (char *)malloc(sz + 1);
+    strcpy(data->curDir, curdir);
+    if(curdir[sz - 1] == '\0')
+	strcat(data->curDir, "/");
     
     if (data->files) {
 	    for(i=0;i<data->nFiles;i++) {