incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From long...@apache.org
Subject [1/4] qt commit: fixes for File api: file and file entry, 81
Date Mon, 14 May 2012 21:02:40 GMT
Updated Branches:
  refs/heads/master 14b3d436b -> f5a647265


fixes for File api: file and file entry, 81


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/commit/f5a64726
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/f5a64726
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/f5a64726

Branch: refs/heads/master
Commit: f5a64726529b97a859826055cd11fc786acc3c92
Parents: a7e4ce0
Author: Longwei Su <lsu@ics.com>
Authored: Mon May 14 17:01:47 2012 -0400
Committer: Longwei Su <lsu@ics.com>
Committed: Mon May 14 17:01:47 2012 -0400

----------------------------------------------------------------------
 src/plugins/fileapi.cpp |   51 +++++++++++++++++++++++-------------------
 www/js/file.js          |   47 +++++++++++++++++++++++++-------------
 2 files changed, 59 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/f5a64726/src/plugins/fileapi.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/fileapi.cpp b/src/plugins/fileapi.cpp
index b3cb3d5..28d0448 100644
--- a/src/plugins/fileapi.cpp
+++ b/src/plugins/fileapi.cpp
@@ -244,7 +244,7 @@ void FileAPI::removeRecursively( int scId, int ecId, QString p_path )
{
     }
 
     // Something went wrong if we reach here
-    this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR
)" );
+    this->callback( ecId, "FileException.cast( FileException.NO_MODIFICATION_ALLOWED_ERR
)" );
 }
 
 /**
@@ -260,7 +260,7 @@ void FileAPI::file( int scId, int ecId, QString p_path ) {
         return;
     }
     else {
-        this->callback( scId, "FileInfo.cast( '" + fileInfo.fileName() + "', '" + fileInfo.absoluteFilePath()
+ "', 'unknown/unknown', new Date(" + QString::number(fileInfo.lastModified().toMSecsSinceEpoch())
+ "), " + QString::number(fileInfo.size()) + " )" );
+        this->callback( scId, "File.cast( '" + fileInfo.fileName() + "', '" + fileInfo.absoluteFilePath()
+ "', 'unknown/unknown', new Date(" + QString::number(fileInfo.lastModified().toMSecsSinceEpoch())
+ "), " + QString::number(fileInfo.size()) + " )" );
         return;
     }
 }
@@ -480,25 +480,30 @@ void FileAPI::readAsDataURL( int scId, int ecId, QString p_path ) {
  */
 bool FileAPI::rmDir( QDir p_dir ) {
     qDebug() << Q_FUNC_INFO << p_dir;
-    //    if( p_dir.exists() ) {
-    //        // Iterate over entries and remove them
-    //        Q_FOREACH( const QFileInfo &fileInfo, p_dir.entryInfoList( QDir::Dirs |
QDir::Files | QDir::NoDotAndDotDot ) ) {
-    //            if( fileInfo.isDir() ) {
-    //                if( !FileAPI::rmDir( fileInfo.dir() ) ) {
-    //                    return false;
-    //                }
-    //            }
-    //            else {
-    //                if( !QFile::remove( fileInfo.absoluteFilePath() ) ) {
-    //                    return false;
-    //                }
-    //            }
-    //        }
-
-    //        // Finally remove the current dir
-    //        qDebug() << p_dir.absolutePath();
-    //        return p_dir.rmdir( p_dir.absolutePath() );
-    //    }
-
-    return false;
+    QDir dir = QDir::current();
+    QString absPath = dir.absolutePath() + "/doc";
+    if ( p_dir == absPath){//can't remove root dir
+        return false;
+    }
+    bool result = true;
+       if( p_dir.exists() ) {
+           // Iterate over entries and remove them
+           Q_FOREACH( const QFileInfo &fileInfo, p_dir.entryInfoList( QDir::Dirs | QDir::Files
| QDir::NoDotAndDotDot ) ) {
+               if (fileInfo.isDir()) {
+                   result = rmDir(fileInfo.absoluteFilePath());
+               }
+               else {
+                   result = QFile::remove(fileInfo.absoluteFilePath());
+               }
+
+               if (!result) {
+                   return result;
+               }
+           }
+
+           // Finally remove the current dir
+           qDebug() << p_dir.absolutePath();
+           return p_dir.rmdir( p_dir.absolutePath() );
+       }
+       return result;
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/f5a64726/www/js/file.js
----------------------------------------------------------------------
diff --git a/www/js/file.js b/www/js/file.js
index 4eaf7bd..19b4ba3 100644
--- a/www/js/file.js
+++ b/www/js/file.js
@@ -137,24 +137,39 @@ Entry.prototype.getParent = function( successCallback, errorCallback
) {
  * (had to call the 'File' object FileInfo since there were name conflicts)
  * http://dev.w3.org/2006/webapi/FileAPI/#dfn-file
  */
-function FileInfo() {
-}
-
-FileInfo.cast = function( p_name, p_fullPath, p_type, p_lastModifiedDate, p_size ) {
-            var f = new FileInfo();
-            f.name = p_name;
-            f.fullPath = p_fullPath;
-            f.type = p_type;
-            f.lastModifiedDate = p_lastModifiedDate;
-            f.size = p_size;
-
+//function FileInfo() {
+//}
+
+//FileInfo.cast = function( p_name, p_fullPath, p_type, p_lastModifiedDate, p_size ) {
+//            var f = new FileInfo();
+//            f.name = p_name;
+//            f.fullPath = p_fullPath;
+//            f.type = p_type;
+//            f.lastModifiedDate = p_lastModifiedDate;
+//            f.size = p_size;
+
+//            return f;
+//        }
+//FileInfo.prototype.name = "";
+//FileInfo.prototype.fullPath = "";
+//FileInfo.prototype.type = "unknown/unknown";
+//FileInfo.prototype.lastModifiedDate = null;
+//FileInfo.prototype.size = 0;
+
+//Rework, have to overwrite it to pass the test-cast,
+function File(name, fullPath, type, lastModifiedDate, size) {
+         this.name = name || null;
+  this.fullPath = fullPath || null;
+        this.type = type || null;
+   this.lastModifiedDate = lastModifiedDate || null;
+     this.size = size || 0;
+ }
+
+File.cast = function( p_name, p_fullPath, p_type, p_lastModifiedDate, p_size ) {
+            var f = new File(p_name, p_fullPath, p_type, p_lastModifiedDate, p_size);
             return f;
         }
-FileInfo.prototype.name = "";
-FileInfo.prototype.fullPath = "";
-FileInfo.prototype.type = "unknown/unknown";
-FileInfo.prototype.lastModifiedDate = null;
-FileInfo.prototype.size = 0;
+
 
 /**
  * FileSaver interface


Mime
View raw message