gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash/server/asobj SharedObject.cpp


From: Rob Savoye
Subject: [Gnash-commit] gnash/server/asobj SharedObject.cpp
Date: Fri, 21 Dec 2007 02:15:19 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Rob Savoye <rsavoye>    07/12/21 02:15:19

Modified files:
        server/asobj   : SharedObject.cpp 

Log message:
                * server/asobj/SharedObject.cpp: Create all the directory
                components in the path name if they don't exist.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SharedObject.cpp?cvsroot=gnash&r1=1.18&r2=1.19

Patches:
Index: SharedObject.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/SharedObject.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- SharedObject.cpp    21 Dec 2007 00:56:06 -0000      1.18
+++ SharedObject.cpp    21 Dec 2007 02:15:19 -0000      1.19
@@ -24,6 +24,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <boost/tokenizer.hpp>
 
 #include "amf.h"
 #include "sol.h"
@@ -48,6 +49,7 @@
 }
 
 using namespace amf;
+using namespace boost;
 
 namespace gnash {
 
@@ -256,20 +258,44 @@
     string url_s;
     const URL& baseurl = get_base_url();
     URL url(url_s, baseurl);
-    log_msg(_("BASE URL=%s (%s)"), baseurl.str().c_str(), 
url.hostname().c_str());
+//    log_msg(_("BASE URL=%s (%s)"), baseurl.str().c_str(), 
url.hostname().c_str());
     
     if (url.hostname().size() == 0) {
         strcpy(domain, "localhost");
     }
     
     newspec += domain;
-    int ret = mkdir(newspec.c_str(), S_IRUSR|S_IWUSR|S_IXUSR);
     newspec += "/";
+    if (obj->getFilespec().find("/", 0) != string::npos) {
+        typedef tokenizer<char_separator<char> > Tok;
+        char_separator<char> sep("/");
+        Tok t(obj->getFilespec(), sep);
+        tokenizer<char_separator <char> >::iterator tit;
+        string newdir = newspec;
+        for(tit=t.begin(); tit!=t.end();++tit){
+            cout << *tit << "\n";
+            newdir += *tit;
+            if (newdir.find("..", 0 != string::npos)) {
+                return as_value(false);
+            }
+            if (newdir.rfind(".sol", newdir.size()) == string::npos) {
+                int ret = mkdir(newdir.c_str(), S_IRUSR|S_IWUSR|S_IXUSR);
     if ((errno != EEXIST) && (ret != 0)) {
         log_error("Couldn't create directory for .sol files: %s\n\t%s",
-                  newspec.c_str(), strerror(errno));
+                              newdir.c_str(), strerror(errno));
         return as_value(false);
     }
+            }
+            newdir += "/";
+        }
+    }
+    
+//     int ret = mkdir(newspec.c_str(), S_IRUSR|S_IWUSR|S_IXUSR);
+//     if ((errno != EEXIST) && (ret != 0)) {
+//         log_error("Couldn't create directory for .sol files: %s\n\t%s",
+//                   newspec.c_str(), strerror(errno));
+//         return as_value(false);
+//     }
     
     newspec += obj->getFilespec();
     obj->setFilespec(newspec);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]