Commits

ryanackley committed b62f057

Added a bunch of code to prevent random crashes. It will now always check to make sure a file exists and is of the right type before attempting an operation

Comments (0)

Files changed (1)

NPAPIFileIOforChromeAPI.cpp

 {
     if (!strPath.length())
     {
-        return true;
+        return false;
     }
     path p(strPath);
     
+    if (exists(p))
+    {
+        if (is_regular_file(p))
+        {
+            return false;
+        }
+        return true;
+    }
+    
     create_directory(p);
     return is_directory(p);
 }
        
     path p(strPath);
    
+    if (exists(p) && is_directory(p))
+    {
+        return false;
+    }
     /*int fileLen = (int)lenProp.cast<double>();
     char buffer[fileLen];
     
     path p(strPath);
     
     VariantList entries;
-    if (is_directory(p))
+    if (exists(p) && is_directory(p))
     {
         directory_iterator di(p);
         directory_iterator eos;
     
     
     //VariantList jsBytes;
-    if (is_regular_file(p))
+    if (exists(p) && is_regular_file(p))
     {
         int size = file_size(p);
         char* buffer = new char[size];
 int NPAPIFileIOforChromeAPI::getFileSize(std::string strPath)
 {
     path p(strPath);
-    return file_size(p);
+    if (exists(p) && is_regular_file(p))
+    {
+        return file_size(p);
+    }
+    else
+    {
+        return 0;
+    }
 }
 bool NPAPIFileIOforChromeAPI::isDirectory(std::string strPath)
 {
     path p(strPath);
-    return is_directory(p);
+    return exists(p) && is_directory(p);
 }
 bool NPAPIFileIOforChromeAPI::fileExists(std::string strPath)
 {
 bool NPAPIFileIOforChromeAPI::removeRecursively(std::string strPath)
 {
     path p(strPath);
-    return remove_all(p) != 0;
+    if (exists(p))
+    {
+        return remove_all(p) != 0;
+    }
+    else
+    {
+        return false;
+    }
 }
 
 void NPAPIFileIOforChromeAPI::launchFolderSelect(JSObjectPtr callback)