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 19:58:29 UTC
qt commit: minor fixes for seek
Updated Branches:
refs/heads/master 6ab1d8efb -> 570de8bc0
minor fixes for seek
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/570de8bc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/570de8bc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/570de8bc
Branch: refs/heads/master
Commit: 570de8bc08e5080d791b00e7c62bd522f9b7eae7
Parents: 6ab1d8e
Author: Longwei Su <ls...@ics.com>
Authored: Thu May 31 13:58:04 2012 -0400
Committer: Longwei Su <ls...@ics.com>
Committed: Thu May 31 13:58:04 2012 -0400
----------------------------------------------------------------------
src/plugins/fileapi.cpp | 8 ++++++++
www/js/file.js | 2 +-
2 files changed, 9 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/570de8bc/src/plugins/fileapi.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/fileapi.cpp b/src/plugins/fileapi.cpp
index 98cf8ae..9dc8013 100644
--- a/src/plugins/fileapi.cpp
+++ b/src/plugins/fileapi.cpp
@@ -90,6 +90,7 @@ void FileAPI::requestFileSystem( int scId, int ecId, unsigned short p_type, unsi
void FileAPI::resolveLocalFileSystemURL( int scId, int ecId, QString p_url ) {
// qDebug() << Q_FUNC_INFO << QString(p_url);
QUrl url = QUrl::fromUserInput( p_url );
+ QUrl urls(p_url);
// Check if we have a valid URL
if( !url.isValid() ) {
this->callback( ecId, "FileException.cast( FileException.ENCODING_ERR )" );
@@ -311,6 +312,7 @@ void FileAPI::write( int scId, int ecId, QString p_path, unsigned long long p_po
// Create TextStream for writing
QTextStream textStream( &file );
textStream.setCodec( "UTF-8" );
+ textStream.setAutoDetectUnicode(true);
// Seek to correct position
if( !textStream.seek( p_position ) ) {
@@ -327,6 +329,12 @@ void FileAPI::write( int scId, int ecId, QString p_path, unsigned long long p_po
file.flush();
file.close();
fileInfo.refresh();
+ if(p_position > 0){
+ if(!file.resize(p_position + p_data.size()) ){
+ this->callback( ecId, "FileException.cast( FileException.NO_MODIFICATION_ALLOWED_ERR ), " + QString::number(file.size()) + ", " + QString::number(file.size()) );
+ return;
+ }
+ }
// Hooray - we are done!
this->callback( scId, QString::number(fileInfo.size()) + ", " + QString::number(fileInfo.size()) );
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/570de8bc/www/js/file.js
----------------------------------------------------------------------
diff --git a/www/js/file.js b/www/js/file.js
index 5baa114..87b2a42 100644
--- a/www/js/file.js
+++ b/www/js/file.js
@@ -290,7 +290,7 @@ FileWriter.prototype.seek = function( offset ) {
if( this.readyState == FileSaver.WRITING ) throw FileException.cast(FileException.INVALID_STATE_ERR);
if( offset < 0 ) {
- this.position = offset + this.length;
+ this.position = Math.max(offset + this.length, 0);
}
else if( offset > this.length ) {
this.position = this.length;