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/31 17:07:57 UTC
qt commit: fixes for file write
Updated Branches:
refs/heads/master a356ac561 -> 6ab1d8efb
fixes for file write
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/6ab1d8ef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/6ab1d8ef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/6ab1d8ef
Branch: refs/heads/master
Commit: 6ab1d8efbe32d6c0b463fc72d679f7d723acdc6e
Parents: a356ac5
Author: Longwei Su <ls...@ics.com>
Authored: Thu May 31 11:06:18 2012 -0400
Committer: Longwei Su <ls...@ics.com>
Committed: Thu May 31 11:06:18 2012 -0400
----------------------------------------------------------------------
src/plugins/fileapi.cpp | 6 +++++-
www/js/file.js | 15 ++++++++++-----
2 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/6ab1d8ef/src/plugins/fileapi.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/fileapi.cpp b/src/plugins/fileapi.cpp
index e8f40dd..98cf8ae 100644
--- a/src/plugins/fileapi.cpp
+++ b/src/plugins/fileapi.cpp
@@ -286,8 +286,12 @@ void FileAPI::file( int scId, int ecId, QString p_path ) {
* FileWriter.write - http://www.w3.org/TR/file-writer-api/#widl-FileWriter-write
*/
void FileAPI::write( int scId, int ecId, QString p_path, unsigned long long p_position, QString p_data ) {
- qDebug() << Q_FUNC_INFO << p_path <<p_position <<p_data;
+ qDebug() << Q_FUNC_INFO << QString(p_path) << p_position <<p_data;
QFile file( p_path );
+ if(!file.exists()){
+ file.open( QIODevice::WriteOnly );
+ file.close();
+ }
// Check if file exists
if( !file.exists() ) {
this->callback( ecId, "FileException.cast( FileException.NOT_FOUND_ERR ), 0, 0" );
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/6ab1d8ef/www/js/file.js
----------------------------------------------------------------------
diff --git a/www/js/file.js b/www/js/file.js
index 7367729..5baa114 100644
--- a/www/js/file.js
+++ b/www/js/file.js
@@ -184,6 +184,7 @@ File.cast = function( p_name, p_fullPath, p_type, p_lastModifiedDate, p_size ) {
* FileSaver interface
* http://www.w3.org/TR/file-writer-api/#idl-def-FileSaver
*/
+
function FileSaver() {
}
@@ -220,25 +221,29 @@ FileSaver.prototype.onabort = null;
FileSaver.prototype.onerror = null;
FileSaver.prototype.onwriteend = null;
-FileSaver.prototype.fullPath = ""; // Not W3C conform, but we need the path for handling!
+//FileSaver.prototype.fullPath = ""; // Not W3C conform, but we need the path for handling!
/**
* FileWriter interface
* (derives from FileSaver)
* http://www.w3.org/TR/file-writer-api/#idl-def-FileWriter
*/
-function FileWriter() {
+
+function FileWriter(p_file) {
+ this.fullPath = p_file.fullPath || "";
+ return this;
}
+
FileWriter.cast = function( p_fullPath, p_length ) {
- var fw = new FileWriter();
- fw.fullPath = p_fullPath;
- fw.length = p_length;
+ var tmpFile = new File(null,p_fullPath,null, null,null);
+ var fw = new FileWriter(tmpFile);
return fw;
}
FileWriter.prototype = new FileSaver();
+FileWriter.prototype.fullPath = "";
FileWriter.prototype.position = 0;
FileWriter.prototype.length = 0;
FileWriter.prototype.write = function( data ) {