You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2012/05/15 07:37:18 UTC
qt commit: fixes for corner test input
Updated Branches:
refs/heads/master f5a647265 -> 857070180
fixes for corner test input
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/85707018
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/85707018
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/85707018
Branch: refs/heads/master
Commit: 857070180cfbc108cc753c8826d74871c2d011df
Parents: f5a6472
Author: Longwei Su <lo...@apache.org>
Authored: Tue May 15 01:37:00 2012 -0400
Committer: Longwei Su <lo...@apache.org>
Committed: Tue May 15 01:37:00 2012 -0400
----------------------------------------------------------------------
src/plugins/fileapi.cpp | 64 +++++++++++++++++++++++------------------
www/js/file.js | 5 +++
2 files changed, 41 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/85707018/src/plugins/fileapi.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/fileapi.cpp b/src/plugins/fileapi.cpp
index 28d0448..274c5a9 100644
--- a/src/plugins/fileapi.cpp
+++ b/src/plugins/fileapi.cpp
@@ -346,12 +346,19 @@ void FileAPI::getParent( int scId, int ecId, QString p_path ) {
qDebug() << Q_FUNC_INFO << p_path;
+ //can't cdup more than app's root
+ QDir root = QDir::current();
+ QString absPath = root.absolutePath() + "/doc";
// Try to change into upper directory
- if( !dir.cdUp() ) {
- this->callback( ecId, "FileException.cast( FileException.NOT_FOUND_ERR )" );
- return;
+ if( p_path != absPath){
+ if( !dir.cdUp() ) {
+ this->callback( ecId, "FileException.cast( FileException.NOT_FOUND_ERR )" );
+ return;
+ }
+
}
+
// Extract names and send back
this->callback( scId, "DirectoryEntry.cast( '" + dir.dirName() + "', '" + dir.absolutePath() + "' )" );
return;
@@ -364,10 +371,11 @@ void FileAPI::remove( int scId, int ecId, QString p_path ) {
QFileInfo fileInfo(p_path);
qDebug() << Q_FUNC_INFO << p_path;
-
+ QDir root = QDir::current();
+ QString absPath = root.absolutePath() + "/doc";
// Check if entry exists at all
- if( !fileInfo.exists() ) {
- this->callback( ecId, "FileException.cast( FileException.NOT_FOUND_ERR )" );
+ if( !fileInfo.exists() || (p_path == absPath)) {
+ this->callback( ecId, "FileException.cast( FileException.NO_MODIFICATION_ALLOWED_ERR )" );
return;
}
@@ -390,7 +398,7 @@ void FileAPI::remove( int scId, int ecId, QString p_path ) {
}
// Something went wrong if we reached here
- this->callback( ecId, "FileException.cast( FileException.NO_MODIFICATION_ALLOWED_ERR )" );
+ this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" );
return;
}
@@ -409,7 +417,7 @@ void FileAPI::getMetadata( int scId, int ecId, QString p_path ) {
}
// Return modification date
- this->callback( scId, "FileMetadata.cast( new Date(" + QString::number(fileInfo.lastModified().toMSecsSinceEpoch()) + ") )" );
+ this->callback( scId, "Metadata.cast( new Date(" + QString::number(fileInfo.lastModified().toMSecsSinceEpoch()) + ") )" );
return;
}
@@ -486,24 +494,24 @@ bool FileAPI::rmDir( QDir p_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;
+ 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/85707018/www/js/file.js
----------------------------------------------------------------------
diff --git a/www/js/file.js b/www/js/file.js
index 19b4ba3..9df2d70 100644
--- a/www/js/file.js
+++ b/www/js/file.js
@@ -116,6 +116,11 @@ Entry.prototype.getMetadata = function( successCallback, errorCallback ) {
// Get metadata for this entry
Cordova.exec(successCallback, errorCallback, "com.cordova.File", "getMetadata", [this.fullPath]);
}
+Entry.prototype.setMetadata = function( successCallback, errorCallback ) {
+ //Cordova.exec(successCallback, errorCallback, "com.cordova.File", "setMetadata", [this.fullPath]);
+ }
+Entry.prototype.moveTo = function( parent, newName, successCallback, errorCallback ) {
+ }
Entry.prototype.moveTo = function( parent, newName, successCallback, errorCallback ) {
}
Entry.prototype.copyTo = function( parent, newName, successCallback, errorCallback ) {